X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/eb71219dd04260a4e8b9f850c4e3ef1c1f3c82c7..dc0e23b8fb35c8b0e527594f96fa91c57a067b3a:/src/mac/pnghand.cpp diff --git a/src/mac/pnghand.cpp b/src/mac/pnghand.cpp index 193676f195..3d2690803c 100644 --- a/src/mac/pnghand.cpp +++ b/src/mac/pnghand.cpp @@ -39,6 +39,7 @@ #include "wx/bitmap.h" #include "wx/mac/pnghand.h" #include "wx/mac/pngread.h" +#include "wx/mac/private.h" extern "C" { #include "png.h" @@ -110,13 +111,12 @@ wxPNGReader::Create(int width, int height, int depth, int colortype) Width = width; Height = height; Depth = depth; ColorType = (colortype>=0) ? colortype: ((Depth>8) ? COLORTYPE_COLOR: 0); delete m_palette; - delete[] RawImage ; - RawImage = 0; - m_palette = 0; + m_palette = NULL; + delete[] RawImage; + RawImage = NULL; - if (lpbi) - { - wxMacDestroyGWorld( lpbi ) ; + if (lpbi) { + wxMacDestroyGWorld( (GWorldPtr) lpbi ) ; } lpbi = wxMacCreateGWorld( Width , Height , Depth); if (lpbi) @@ -133,11 +133,18 @@ wxPNGReader::Create(int width, int height, int depth, int colortype) wxPNGReader::~wxPNGReader ( ) { - delete[] RawImage ; - if (lpbi) { - wxMacDestroyGWorld( lpbi ) ; - } - delete m_palette; + if (RawImage != NULL) { + delete[] RawImage ; + RawImage = NULL; + } + if (lpbi) { + wxMacDestroyGWorld( (GWorldPtr) lpbi ) ; + lpbi = NULL; + } + if (m_palette != NULL) { + delete m_palette; + m_palette = NULL; + } } @@ -258,11 +265,13 @@ wxPNGReader::SetPalette(int n, rgb_color_struct *rgb_struct) void wxPNGReader::NullData() { if (lpbi) { - wxMacDestroyGWorld( lpbi ) ; + wxMacDestroyGWorld( (GWorldPtr) lpbi ) ; + lpbi = NULL; + } + if (m_palette != NULL) { + delete m_palette; + m_palette = NULL; } - delete m_palette; - lpbi = NULL; - m_palette = NULL; } wxBitmap* wxPNGReader::GetBitmap(void) @@ -431,7 +440,7 @@ bool wxPNGReader::ReadFile(char * ImageFileName) if (!info_ptr) { fclose(fp); - delete(png_ptr); + delete png_ptr; return FALSE; } /* set error handling */ @@ -439,8 +448,8 @@ bool wxPNGReader::ReadFile(char * ImageFileName) { png_read_destroy(png_ptr, info_ptr, (png_info *)0); fclose(fp); - delete(png_ptr); - delete(info_ptr); + delete png_ptr; + delete info_ptr; /* If we get here, we had a problem reading the file */ return FALSE; @@ -512,7 +521,7 @@ bool wxPNGReader::ReadFile(char * ImageFileName) GetGWorld( &origPort , &origDevice ) ; // ignore shapedc - SetGWorld( lpbi , NULL ) ; + SetGWorld( (GWorldPtr) lpbi , NULL ) ; do { // (unsigned char *)iter.GetRow(); @@ -622,8 +631,8 @@ bool wxPNGReader::ReadFile(char * ImageFileName) png_read_destroy(png_ptr, info_ptr, (png_info *)0); /* free the structures */ - delete(png_ptr); - delete(info_ptr); + delete png_ptr; + delete info_ptr; /* close the file */ fclose(fp); @@ -662,7 +671,7 @@ bool wxPNGReader::SaveFile(char * ImageFileName) if (!info_ptr) { fclose(fp); - delete(png_ptr); + delete png_ptr; return FALSE; } @@ -671,8 +680,8 @@ bool wxPNGReader::SaveFile(char * ImageFileName) { png_write_destroy(png_ptr); fclose(fp); - delete(png_ptr); - delete(info_ptr); + delete png_ptr; + delete info_ptr; /* If we get here, we had a problem reading the file */ return FALSE; @@ -769,8 +778,8 @@ bool wxPNGReader::SaveFile(char * ImageFileName) delete[] (info_ptr->palette); /* free the structures */ - delete(png_ptr); - delete(info_ptr); + delete png_ptr; + delete info_ptr; /* close the file */ fclose(fp);