From 0228d578ee91d26e730941c3c3c193a544e79906 Mon Sep 17 00:00:00 2001 From: Artur Wieczorek Date: Fri, 11 Jul 2014 17:25:39 +0000 Subject: [PATCH] Allow clearing wxPG from within wxPG event handlers. If wxPG::Clear is called from within event handler then it is not possible to delete all property items directly because some vital internal wxPG data are still in use. In this case it is necessary to put all items on the list for deferred deletion in wxPG idle state. Closes #16222. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@76890 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/propgrid/propgridpagestate.cpp | 33 ++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/src/propgrid/propgridpagestate.cpp b/src/propgrid/propgridpagestate.cpp index 4c8f482fa8..84ed9d2340 100644 --- a/src/propgrid/propgridpagestate.cpp +++ b/src/propgrid/propgridpagestate.cpp @@ -286,18 +286,33 @@ void wxPropertyGridPageState::DoClear() m_selection.clear(); } - m_regularArray.Empty(); - if ( m_abcArray ) - m_abcArray->Empty(); + // If handling wxPG event then every property item must be + // deleted individually (and with deferral). + if ( m_pPropGrid && m_pPropGrid->m_processedEvent ) + { + wxPropertyGridIterator it; + for ( it = m_pPropGrid->GetIterator(wxPG_ITERATE_ALL); + !it.AtEnd(); + it++ ) + { + DoDelete(*it, true); + } + } + else + { + m_regularArray.Empty(); + if ( m_abcArray ) + m_abcArray->Empty(); - m_dictName.clear(); + m_dictName.clear(); - m_currentCategory = NULL; - m_lastCaptionBottomnest = 1; - m_itemsAdded = 0; + m_currentCategory = NULL; + m_lastCaptionBottomnest = 1; + m_itemsAdded = 0; - m_virtualHeight = 0; - m_vhCalcPending = 0; + m_virtualHeight = 0; + m_vhCalcPending = 0; + } } // -----------------------------------------------------------------------