fixed FindOrCreatePen/Brush() for the case when the object couldn't be created successfully
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@9483 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -21,6 +21,7 @@ All (GUI):
|
|||||||
- new wxToggleButton class (John Norris, Axel Schlueter)
|
- new wxToggleButton class (John Norris, Axel Schlueter)
|
||||||
- wxCalendarCtrl now highlighting the date with time part bug fixed
|
- wxCalendarCtrl now highlighting the date with time part bug fixed
|
||||||
- wxADJUST_MINSIZE sizer flag added
|
- wxADJUST_MINSIZE sizer flag added
|
||||||
|
- FindOrCreateBrush/Pen() bug fix for invalid colour values
|
||||||
|
|
||||||
wxMSW:
|
wxMSW:
|
||||||
|
|
||||||
|
@@ -532,7 +532,15 @@ wxPen *wxPenList::FindOrCreatePen (const wxColour& colour, int width, int style)
|
|||||||
each_pen->GetColour ().Blue () == colour.Blue ())
|
each_pen->GetColour ().Blue () == colour.Blue ())
|
||||||
return each_pen;
|
return each_pen;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxPen *pen = new wxPen (colour, width, style);
|
wxPen *pen = new wxPen (colour, width, style);
|
||||||
|
if ( !pen->Ok() )
|
||||||
|
{
|
||||||
|
// don't save the invalid pens in the list
|
||||||
|
delete pen;
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
// Yes, we can return a pointer to this in a later FindOrCreatePen call,
|
// Yes, we can return a pointer to this in a later FindOrCreatePen call,
|
||||||
// because we created it within FindOrCreatePen. Safeguards against
|
// because we created it within FindOrCreatePen. Safeguards against
|
||||||
@@ -575,14 +583,22 @@ wxBrush *wxBrushList::FindOrCreateBrush (const wxColour& colour, int style)
|
|||||||
return each_brush;
|
return each_brush;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wxBrush *brush = new wxBrush (colour, style);
|
||||||
|
|
||||||
|
if ( !brush->Ok() )
|
||||||
|
{
|
||||||
|
// don't put the brushes we failed to create into the list
|
||||||
|
delete brush;
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
brush->SetVisible(TRUE);
|
||||||
|
|
||||||
// Yes, we can return a pointer to this in a later FindOrCreateBrush call,
|
// Yes, we can return a pointer to this in a later FindOrCreateBrush call,
|
||||||
// because we created it within FindOrCreateBrush. Safeguards against
|
// because we created it within FindOrCreateBrush. Safeguards against
|
||||||
// returning a pointer to an automatic variable and hanging on to it
|
// returning a pointer to an automatic variable and hanging on to it
|
||||||
// (dangling pointer).
|
// (dangling pointer).
|
||||||
wxBrush *brush = new wxBrush (colour, style);
|
|
||||||
|
|
||||||
brush->SetVisible(TRUE);
|
|
||||||
|
|
||||||
return brush;
|
return brush;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user