Don't attempt to delete root wxPGProperty in propgrid sample
The root wxPGProperty is not designed to be deleted so we should look for a property to delete in the collection of its child properties. Closes #18539.
This commit is contained in:
@@ -2319,18 +2319,19 @@ void FormMain::OnDelPropRClick( wxCommandEvent& WXUNUSED(event) )
|
||||
|
||||
for (;;)
|
||||
{
|
||||
if ( p->GetChildCount() == 0 )
|
||||
break;
|
||||
|
||||
unsigned int n = static_cast<unsigned int>(rand()) % p->GetChildCount();
|
||||
p = p->Item(n);
|
||||
|
||||
if ( !p->IsCategory() )
|
||||
{
|
||||
m_pPropGridManager->DeleteProperty( p );
|
||||
wxString label = p->GetLabel();
|
||||
m_pPropGridManager->DeleteProperty(p);
|
||||
wxLogMessage("Property deleted: %s", label);
|
||||
break;
|
||||
}
|
||||
|
||||
if ( !p->GetChildCount() )
|
||||
break;
|
||||
|
||||
int n = rand() % ((int)p->GetChildCount());
|
||||
|
||||
p = p->Item(n);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user