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:
Artur Wieczorek
2019-10-23 18:02:35 +02:00
parent 1b063e1dea
commit a60c5b36fe

View File

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