X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/cb38104ec72711ec976af5e441a7efd5d5da77db..6f34921d9369a31de14e4b07e4824e2d701710f0:/src/common/gdicmn.cpp diff --git a/src/common/gdicmn.cpp b/src/common/gdicmn.cpp index e67704f9b5..4bb0019e0d 100644 --- a/src/common/gdicmn.cpp +++ b/src/common/gdicmn.cpp @@ -271,7 +271,7 @@ wxColour *wxColourDatabase::FindColour(const wxString& colour) if (!(col->Ok())) { delete col; - return NULL; + return (wxColour *) NULL; } Append( colour, col ); return col; @@ -440,30 +440,34 @@ wxBitmapList::wxBitmapList () wxBitmapList::~wxBitmapList () { wxLogDebug("~wxBitmapList: count = %d", Number()); +#ifdef __WXMSW__ wxNode *node = First (); while (node) { wxBitmap *bitmap = (wxBitmap *) node->Data (); wxNode *next = node->Next (); - delete bitmap; -// bitmap->FreeResource(TRUE); + if (bitmap->GetVisible()) + delete bitmap; node = next; } +#endif } // Pen and Brush lists wxPenList::~wxPenList () { +#ifdef __WXMSW__ wxNode *node = First (); while (node) { wxPen *pen = (wxPen *) node->Data (); wxNode *next = node->Next (); - delete pen; -// pen->FreeResource(TRUE); + if (pen->GetVisible()) + delete pen; node = next; } +#endif } void wxPenList::AddPen (wxPen * pen) @@ -505,19 +509,22 @@ wxPen *wxPenList::FindOrCreatePen (const wxString& colour, int width, int style) if (the_colour) return FindOrCreatePen (*the_colour, width, style); else - return NULL; + return (wxPen *) NULL; } wxBrushList::~wxBrushList () { +#ifdef __WXMSW__ wxNode *node = First (); while (node) { wxBrush *brush = (wxBrush *) node->Data (); wxNode *next = node->Next (); - delete brush; + if (brush->GetVisible()) + delete brush; node = next; } +#endif } void wxBrushList::AddBrush (wxBrush * brush) @@ -552,7 +559,7 @@ wxBrush *wxBrushList::FindOrCreateBrush (const wxString& colour, int style) if (the_colour) return FindOrCreateBrush (*the_colour, style); else - return NULL; + return (wxBrush *) NULL; } void wxBrushList::RemoveBrush (wxBrush * brush) @@ -566,21 +573,16 @@ wxFontList::~wxFontList () wxNode *node = First (); while (node) { -/* + // Only delete objects that are 'visible', i.e. + // that have been created using FindOrCreate..., + // where the pointers are expected to be shared + // (and therefore not deleted by any one part of an app). wxFont *font = (wxFont *) node->Data (); wxNode *next = node->Next (); - delete font; + if (font->GetVisible()) + delete font; node = next; -*/ - // New for 2.0: don't delete the font (it may be a member - // of a wxDC, for example) - wxFont *font = (wxFont *) node->Data (); - wxNode *next = node->Next (); - - // Force the font to be deleted - font->FreeResource(TRUE); - node = next; - } +} #endif }