From 4c444f19cf1bdb3cb26bb3c123434fe23c808093 Mon Sep 17 00:00:00 2001 From: Julian Smart Date: Wed, 19 Aug 1998 15:45:05 +0000 Subject: [PATCH] GDI double-deletion fix, wxBitmap depth bug git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@610 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/common/gdicmn.cpp | 36 +++++++++++++++++++----------------- src/common/resource.cpp | 2 ++ src/msw/bitmap.cpp | 4 ++-- src/msw/dc.cpp | 7 ++++++- 4 files changed, 29 insertions(+), 20 deletions(-) diff --git a/src/common/gdicmn.cpp b/src/common/gdicmn.cpp index e67704f9b5..1e98af34ef 100644 --- a/src/common/gdicmn.cpp +++ b/src/common/gdicmn.cpp @@ -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) @@ -510,14 +514,17 @@ wxPen *wxPenList::FindOrCreatePen (const wxString& colour, int width, int style) 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) @@ -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; - 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); + if (font->GetVisible()) + delete font; node = next; - } +} #endif } diff --git a/src/common/resource.cpp b/src/common/resource.cpp index 23e87a3e31..9761e7a2d5 100644 --- a/src/common/resource.cpp +++ b/src/common/resource.cpp @@ -99,6 +99,8 @@ void wxInitializeResourceSystem(void) void wxCleanUpResourceSystem(void) { delete wxDefaultResourceTable; + if (wxResourceBuffer) + delete[] wxResourceBuffer; } void wxLogWarning(char *msg) diff --git a/src/msw/bitmap.cpp b/src/msw/bitmap.cpp index fe0edb9f12..d3ed8bc019 100644 --- a/src/msw/bitmap.cpp +++ b/src/msw/bitmap.cpp @@ -133,7 +133,7 @@ wxBitmap::wxBitmap(const char bits[], int the_width, int the_height, int no_bits M_BITMAPDATA->m_depth = no_bits ; M_BITMAPDATA->m_numColors = 0; - M_BITMAPDATA->m_hBitmap = (WXHBITMAP) CreateBitmap(the_width, the_height, no_bits, 1, bits); + M_BITMAPDATA->m_hBitmap = (WXHBITMAP) CreateBitmap(the_width, the_height, 1, no_bits, bits); if (M_BITMAPDATA->m_hBitmap) M_BITMAPDATA->m_ok = TRUE; @@ -190,7 +190,7 @@ bool wxBitmap::Create(int w, int h, int d) if (d > 0) { - M_BITMAPDATA->m_hBitmap = (WXHBITMAP) CreateBitmap(w, h, d, 1, NULL); + M_BITMAPDATA->m_hBitmap = (WXHBITMAP) CreateBitmap(w, h, 1, d, NULL); } else { diff --git a/src/msw/dc.cpp b/src/msw/dc.cpp index bd81c9362d..1e40b8769c 100644 --- a/src/msw/dc.cpp +++ b/src/msw/dc.cpp @@ -412,7 +412,12 @@ void wxDC::DrawArc(long x1,long y1,long x2,long y2, long xc, long yc) long yyy2 = (long) (yyc+ray); if (m_brush.Ok() && m_brush.GetStyle() !=wxTRANSPARENT) { - Pie((HDC) m_hDC,xxx1,yyy1,xxx2,yyy2, + // Have to add 1 to bottom-right corner of rectangle + // to make semi-circles look right (crooked line otherwise). + // Unfortunately this is not a reliable method, depends + // on the size of shape. + // TODO: figure out why this happens! + Pie((HDC) m_hDC,xxx1,yyy1,xxx2+1,yyy2+1, xx1,yy1,xx2,yy2) ; } else -- 2.49.0