From a60c5b36fe3849d3e6439efbb18a0cad00f148a9 Mon Sep 17 00:00:00 2001 From: Artur Wieczorek Date: Wed, 23 Oct 2019 18:02:35 +0200 Subject: [PATCH] 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. --- samples/propgrid/propgrid.cpp | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/samples/propgrid/propgrid.cpp b/samples/propgrid/propgrid.cpp index 4cce1563e2..0951bf00a2 100644 --- a/samples/propgrid/propgrid.cpp +++ b/samples/propgrid/propgrid.cpp @@ -2319,18 +2319,19 @@ void FormMain::OnDelPropRClick( wxCommandEvent& WXUNUSED(event) ) for (;;) { + if ( p->GetChildCount() == 0 ) + break; + + unsigned int n = static_cast(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); } }