From facbd123c2fe59076609775d261158976fbdfaa6 Mon Sep 17 00:00:00 2001 From: Artur Wieczorek Date: Sat, 12 Jul 2014 16:07:54 +0000 Subject: [PATCH] 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 --- src/propgrid/advprops.cpp | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/propgrid/advprops.cpp b/src/propgrid/advprops.cpp index d4deeb707a..42ee76c319 100644 --- a/src/propgrid/advprops.cpp +++ b/src/propgrid/advprops.cpp @@ -1596,17 +1596,21 @@ wxColourProperty::wxColourProperty( const wxString& label, NULL, &gs_wxColourProperty_choicesCache, value ) { - // Extended colour database with custom PG colours. - const char* const* colourLabels = gs_cp_es_normcolour_labels; - for ( int i = 0; *colourLabels; colourLabels++, i++ ) + wxASSERT_MSG( wxTheColourDatabase, wxT("No colour database") ); + if ( wxTheColourDatabase ) { - wxColour clr = wxTheColourDatabase->Find(*colourLabels); - // Use standard wx colour value if its label was found, - // otherwise register custom PG colour. - if ( !clr.IsOk() ) + // Extend colour database with custom PG colours. + const char* const* colourLabels = gs_cp_es_normcolour_labels; + for ( int i = 0; *colourLabels; colourLabels++, i++ ) { - clr.Set(gs_cp_es_normcolour_colours[i]); - wxTheColourDatabase->AddColour(*colourLabels, clr); + wxColour clr = wxTheColourDatabase->Find(*colourLabels); + // 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); + } } }