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:
@@ -1772,6 +1772,9 @@ protected:
|
|||||||
// handling mess).
|
// handling mess).
|
||||||
wxWindow* m_curFocused;
|
wxWindow* m_curFocused;
|
||||||
|
|
||||||
|
// Event currently being sent - NULL if none at the moment
|
||||||
|
wxPropertyGridEvent* m_processedEvent;
|
||||||
|
|
||||||
// Last known top-level parent
|
// Last known top-level parent
|
||||||
wxWindow* m_tlp;
|
wxWindow* m_tlp;
|
||||||
|
|
||||||
|
@@ -431,6 +431,7 @@ void wxPropertyGrid::Init1()
|
|||||||
m_labelEditorProperty = NULL;
|
m_labelEditorProperty = NULL;
|
||||||
m_eventObject = this;
|
m_eventObject = this;
|
||||||
m_curFocused = NULL;
|
m_curFocused = NULL;
|
||||||
|
m_processedEvent = NULL;
|
||||||
m_sortFunction = NULL;
|
m_sortFunction = NULL;
|
||||||
m_inDoPropertyChanged = 0;
|
m_inDoPropertyChanged = 0;
|
||||||
m_inCommitChangesFromEditor = 0;
|
m_inCommitChangesFromEditor = 0;
|
||||||
@@ -579,6 +580,23 @@ wxPropertyGrid::~wxPropertyGrid()
|
|||||||
{
|
{
|
||||||
size_t i;
|
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);
|
DoSelectProperty(NULL, wxPG_SEL_NOVALIDATE|wxPG_SEL_DONT_SEND_EVENT);
|
||||||
|
|
||||||
// This should do prevent things from going too badly wrong
|
// This should do prevent things from going too badly wrong
|
||||||
@@ -4365,8 +4383,12 @@ bool wxPropertyGrid::SendEvent( int eventType, wxPGProperty* p,
|
|||||||
evt.SetCanVeto(true);
|
evt.SetCanVeto(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_processedEvent = &evt;
|
||||||
|
|
||||||
wxEvtHandler* evtHandler = m_eventObject->GetEventHandler();
|
wxEvtHandler* evtHandler = m_eventObject->GetEventHandler();
|
||||||
|
|
||||||
|
m_processedEvent = NULL;
|
||||||
|
|
||||||
evtHandler->ProcessEvent(evt);
|
evtHandler->ProcessEvent(evt);
|
||||||
|
|
||||||
return evt.WasVetoed();
|
return evt.WasVetoed();
|
||||||
|
Reference in New Issue
Block a user