From a5d9fe293149684cb285f5d94ecfca2d4beadcb8 Mon Sep 17 00:00:00 2001 From: Artur Wieczorek Date: Thu, 23 Jan 2020 19:41:39 +0100 Subject: [PATCH] Improve parameter validation in wxPGProperty Replace wxASSERT_MSG with wxCHECK_MSG to simplify checking that we don't crash even if wxPGProperty is not attached to a wxPropertyGrid. --- src/propgrid/property.cpp | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/src/propgrid/property.cpp b/src/propgrid/property.cpp index 101ee980ba..d14dc9130f 100644 --- a/src/propgrid/property.cpp +++ b/src/propgrid/property.cpp @@ -1030,12 +1030,8 @@ wxString wxPGProperty::GetValueAsString( int argFlags ) const } #endif wxPropertyGrid* pg = GetGrid(); - wxASSERT_MSG( pg, - wxS("Cannot get valid value for detached property") ); - if ( !pg ) - { - return wxEmptyString; - } + wxCHECK_MSG( pg, wxEmptyString, + wxS("Cannot get valid value for detached property") ); if ( IsValueUnspecified() ) return pg->GetUnspecifiedValueText(argFlags); @@ -2288,9 +2284,9 @@ int wxPGProperty::GetY2( int lh ) const int wxPGProperty::GetY() const { wxPropertyGrid *pg = GetGrid(); - wxASSERT_MSG( pg, - wxS("Cannot obtain coordinates of detached property") ); - return pg ? GetY2(pg->GetRowHeight()) : 0; + wxCHECK_MSG( pg, 0, + wxS("Cannot obtain coordinates of detached property") ); + return GetY2(pg->GetRowHeight()); } // This is used by Insert etc. @@ -2616,12 +2612,8 @@ void wxPGProperty::Empty() wxPGProperty* wxPGProperty::GetItemAtY( unsigned int y ) const { wxPropertyGrid *pg = GetGrid(); - wxASSERT_MSG( pg, - wxS("Cannot obtain property item for detached property") ); - if( !pg ) - { - return NULL; - } + wxCHECK_MSG( pg, NULL, + wxS("Cannot obtain property item for detached property") ); unsigned int nextItem = 0; return GetItemAtY(y, pg->GetRowHeight(), &nextItem);