From: Jaakko Salli Date: Mon, 1 Mar 2010 15:30:03 +0000 (+0000) Subject: Have to implement wxPGProperty::DeleteChildren() differently so that it will work... X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/e4e55c061f2cf3261bdf7928a180f1d973725699 Have to implement wxPGProperty::DeleteChildren() differently so that it will work with deferred property deletion git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@63593 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/src/propgrid/property.cpp b/src/propgrid/property.cpp index 4e82bcc338..893eb3f0a6 100644 --- a/src/propgrid/property.cpp +++ b/src/propgrid/property.cpp @@ -2455,10 +2455,16 @@ void wxPGProperty::DeleteChildren() { wxPropertyGridPageState* state = m_parentState; - while ( GetChildCount() ) + if ( !GetChildCount() ) + return; + + // Because deletion is sometimes deferred, we have to use + // this sort of code for enumerating the child properties. + unsigned int i = GetChildCount(); + while ( i > 0 ) { - wxPGProperty* child = Item(GetChildCount()-1); - state->DoDelete(child, true); + i--; + state->DoDelete(Item(i), true); } }