Notify if the grid is being destroyed in an event generated by it
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@61875 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -431,6 +431,7 @@ void wxPropertyGrid::Init1()
|
||||
m_labelEditorProperty = NULL;
|
||||
m_eventObject = this;
|
||||
m_curFocused = NULL;
|
||||
m_processedEvent = NULL;
|
||||
m_sortFunction = NULL;
|
||||
m_inDoPropertyChanged = 0;
|
||||
m_inCommitChangesFromEditor = 0;
|
||||
@@ -579,6 +580,23 @@ wxPropertyGrid::~wxPropertyGrid()
|
||||
{
|
||||
size_t i;
|
||||
|
||||
if ( m_processedEvent )
|
||||
{
|
||||
// All right... we are being deleted while wxPropertyGrid event
|
||||
// is being sent. Make sure that event propagates as little
|
||||
// as possible (although usually this is not enough to prevent
|
||||
// a crash).
|
||||
m_processedEvent->Skip(false);
|
||||
m_processedEvent->StopPropagation();
|
||||
|
||||
// Let's use wxMessageBox to make the message appear more
|
||||
// reliably (and *before* the crash can happend).
|
||||
::wxMessageBox("wxPropertyGrid was being destroyed in an event "
|
||||
"generated by it. This usually leads to a crash "
|
||||
"so it is recommended to destroy the control "
|
||||
"at idle time instead.");
|
||||
}
|
||||
|
||||
DoSelectProperty(NULL, wxPG_SEL_NOVALIDATE|wxPG_SEL_DONT_SEND_EVENT);
|
||||
|
||||
// This should do prevent things from going too badly wrong
|
||||
@@ -4365,8 +4383,12 @@ bool wxPropertyGrid::SendEvent( int eventType, wxPGProperty* p,
|
||||
evt.SetCanVeto(true);
|
||||
}
|
||||
|
||||
m_processedEvent = &evt;
|
||||
|
||||
wxEvtHandler* evtHandler = m_eventObject->GetEventHandler();
|
||||
|
||||
m_processedEvent = NULL;
|
||||
|
||||
evtHandler->ProcessEvent(evt);
|
||||
|
||||
return evt.WasVetoed();
|
||||
|
Reference in New Issue
Block a user