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.
This commit is contained in:
Artur Wieczorek
2020-01-23 19:41:39 +01:00
parent 590547b87e
commit a5d9fe2931

View File

@@ -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);