Fix deleting editor controls associated with wxPG properties from within event handler.

Editor controls (and their event handlers) deleted from within wxPG event handler shouldn't by deleted in global idle event handler but only in local wxPG event handler because global idle events can be generated also by calling e.g. wxYield when wxPG is not in the real idle state.

Closes #16617

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@78030 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Artur Wieczorek
2014-10-16 22:49:01 +00:00
parent 633b49ef6e
commit c234f5078f
3 changed files with 43 additions and 0 deletions

View File

@@ -539,6 +539,9 @@ wxPropertyGrid::~wxPropertyGrid()
wxS("Close(false).)") );
}
// Delete pending editor controls
DeletePendingObjects();
if ( m_doubleBuffer )
delete m_doubleBuffer;
@@ -3924,6 +3927,20 @@ void wxPropertyGrid::SetupChildEventHandling( wxWindow* argWnd )
NULL, this);
}
void wxPropertyGrid::DeletePendingObjects()
{
#if !WXWIN_COMPATIBILITY_3_0
// Delete pending property editors and their event handlers.
while ( !m_deletedEditorObjects.empty() )
{
wxObject* obj = m_deletedEditorObjects.back();
m_deletedEditorObjects.pop_back();
delete obj;
}
#endif
}
void wxPropertyGrid::DestroyEditorWnd( wxWindow* wnd )
{
if ( !wnd )
@@ -3932,7 +3949,11 @@ void wxPropertyGrid::DestroyEditorWnd( wxWindow* wnd )
wnd->Hide();
// Do not free editors immediately (for sake of processing events)
#if WXWIN_COMPATIBILITY_3_0
wxPendingDelete.Append(wnd);
#else
m_deletedEditorObjects.push_back(wnd);
#endif
}
void wxPropertyGrid::FreeEditors()
@@ -3948,7 +3969,11 @@ void wxPropertyGrid::FreeEditors()
{
wxEvtHandler* handler = m_wndEditor2->PopEventHandler(false);
m_wndEditor2->Hide();
#if WXWIN_COMPATIBILITY_3_0
wxPendingDelete.Append( handler );
#else
m_deletedEditorObjects.push_back(handler);
#endif
DestroyEditorWnd(m_wndEditor2);
m_wndEditor2 = NULL;
}
@@ -3957,7 +3982,11 @@ void wxPropertyGrid::FreeEditors()
{
wxEvtHandler* handler = m_wndEditor->PopEventHandler(false);
m_wndEditor->Hide();
#if WXWIN_COMPATIBILITY_3_0
wxPendingDelete.Append( handler );
#else
m_deletedEditorObjects.push_back(handler);
#endif
DestroyEditorWnd(m_wndEditor);
m_wndEditor = NULL;
}
@@ -5804,6 +5833,9 @@ void wxPropertyGrid::OnIdle( wxIdleEvent& WXUNUSED(event) )
OnTLPChanging(tlp);
}
// Delete pending property editors and their event handlers.
DeletePendingObjects();
//
// Resolve pending property removals
// In order to determine whether deletion/removal