Check if colour database exists before trying to use it in wxColourProperty.

Sanity check in wxColourProperty ctor.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@76894 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Artur Wieczorek
2014-07-12 16:07:54 +00:00
parent 498dc8161c
commit facbd123c2

View File

@@ -1596,17 +1596,21 @@ wxColourProperty::wxColourProperty( const wxString& label,
NULL, NULL,
&gs_wxColourProperty_choicesCache, value ) &gs_wxColourProperty_choicesCache, value )
{ {
// Extended colour database with custom PG colours. wxASSERT_MSG( wxTheColourDatabase, wxT("No colour database") );
const char* const* colourLabels = gs_cp_es_normcolour_labels; if ( wxTheColourDatabase )
for ( int i = 0; *colourLabels; colourLabels++, i++ )
{ {
wxColour clr = wxTheColourDatabase->Find(*colourLabels); // Extend colour database with custom PG colours.
// Use standard wx colour value if its label was found, const char* const* colourLabels = gs_cp_es_normcolour_labels;
// otherwise register custom PG colour. for ( int i = 0; *colourLabels; colourLabels++, i++ )
if ( !clr.IsOk() )
{ {
clr.Set(gs_cp_es_normcolour_colours[i]); wxColour clr = wxTheColourDatabase->Find(*colourLabels);
wxTheColourDatabase->AddColour(*colourLabels, clr); // Use standard wx colour value if its label was found,
// otherwise register custom PG colour.
if ( !clr.IsOk() )
{
clr.Set(gs_cp_es_normcolour_colours[i]);
wxTheColourDatabase->AddColour(*colourLabels, clr);
}
} }
} }