GDI double-deletion fix, wxBitmap depth bug

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@610 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Julian Smart
1998-08-19 15:45:05 +00:00
parent 857f3be5f1
commit 4c444f19cf
4 changed files with 29 additions and 20 deletions

View File

@@ -440,30 +440,34 @@ wxBitmapList::wxBitmapList ()
wxBitmapList::~wxBitmapList () wxBitmapList::~wxBitmapList ()
{ {
wxLogDebug("~wxBitmapList: count = %d", Number()); wxLogDebug("~wxBitmapList: count = %d", Number());
#ifdef __WXMSW__
wxNode *node = First (); wxNode *node = First ();
while (node) while (node)
{ {
wxBitmap *bitmap = (wxBitmap *) node->Data (); wxBitmap *bitmap = (wxBitmap *) node->Data ();
wxNode *next = node->Next (); wxNode *next = node->Next ();
if (bitmap->GetVisible())
delete bitmap; delete bitmap;
// bitmap->FreeResource(TRUE);
node = next; node = next;
} }
#endif
} }
// Pen and Brush lists // Pen and Brush lists
wxPenList::~wxPenList () wxPenList::~wxPenList ()
{ {
#ifdef __WXMSW__
wxNode *node = First (); wxNode *node = First ();
while (node) while (node)
{ {
wxPen *pen = (wxPen *) node->Data (); wxPen *pen = (wxPen *) node->Data ();
wxNode *next = node->Next (); wxNode *next = node->Next ();
if (pen->GetVisible())
delete pen; delete pen;
// pen->FreeResource(TRUE);
node = next; node = next;
} }
#endif
} }
void wxPenList::AddPen (wxPen * pen) void wxPenList::AddPen (wxPen * pen)
@@ -510,14 +514,17 @@ wxPen *wxPenList::FindOrCreatePen (const wxString& colour, int width, int style)
wxBrushList::~wxBrushList () wxBrushList::~wxBrushList ()
{ {
#ifdef __WXMSW__
wxNode *node = First (); wxNode *node = First ();
while (node) while (node)
{ {
wxBrush *brush = (wxBrush *) node->Data (); wxBrush *brush = (wxBrush *) node->Data ();
wxNode *next = node->Next (); wxNode *next = node->Next ();
if (brush->GetVisible())
delete brush; delete brush;
node = next; node = next;
} }
#endif
} }
void wxBrushList::AddBrush (wxBrush * brush) void wxBrushList::AddBrush (wxBrush * brush)
@@ -566,21 +573,16 @@ wxFontList::~wxFontList ()
wxNode *node = First (); wxNode *node = First ();
while (node) 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 (); wxFont *font = (wxFont *) node->Data ();
wxNode *next = node->Next (); wxNode *next = node->Next ();
if (font->GetVisible())
delete font; delete font;
node = next; 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 #endif
} }

View File

@@ -99,6 +99,8 @@ void wxInitializeResourceSystem(void)
void wxCleanUpResourceSystem(void) void wxCleanUpResourceSystem(void)
{ {
delete wxDefaultResourceTable; delete wxDefaultResourceTable;
if (wxResourceBuffer)
delete[] wxResourceBuffer;
} }
void wxLogWarning(char *msg) void wxLogWarning(char *msg)

View File

@@ -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_depth = no_bits ;
M_BITMAPDATA->m_numColors = 0; 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) if (M_BITMAPDATA->m_hBitmap)
M_BITMAPDATA->m_ok = TRUE; M_BITMAPDATA->m_ok = TRUE;
@@ -190,7 +190,7 @@ bool wxBitmap::Create(int w, int h, int d)
if (d > 0) 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 else
{ {

View File

@@ -412,7 +412,12 @@ void wxDC::DrawArc(long x1,long y1,long x2,long y2, long xc, long yc)
long yyy2 = (long) (yyc+ray); long yyy2 = (long) (yyc+ray);
if (m_brush.Ok() && m_brush.GetStyle() !=wxTRANSPARENT) 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) ; xx1,yy1,xx2,yy2) ;
} }
else else