Avoid crashes due to signals/events when destroying wxWindowQT
Don't handle any pending signals or events for the windows about to be destroyed. Closes https://github.com/wxWidgets/wxWidgets/pull/1253
This commit is contained in:
committed by
Vadim Zeitlin
parent
993334c48a
commit
c42bda6bd5
@@ -241,7 +241,25 @@ wxWindowQt::wxWindowQt(wxWindowQt *parent, wxWindowID id, const wxPoint& pos, co
|
|||||||
|
|
||||||
wxWindowQt::~wxWindowQt()
|
wxWindowQt::~wxWindowQt()
|
||||||
{
|
{
|
||||||
SendDestroyEvent();
|
if ( !m_qtWindow )
|
||||||
|
{
|
||||||
|
wxLogTrace(TRACE_QT_WINDOW, wxT("wxWindow::~wxWindow %s m_qtWindow is NULL"), GetName());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Delete only if the qt widget was created or assigned to this base class
|
||||||
|
wxLogTrace(TRACE_QT_WINDOW, wxT("wxWindow::~wxWindow %s m_qtWindow=%p"), GetName(), m_qtWindow);
|
||||||
|
|
||||||
|
if ( !IsBeingDeleted() )
|
||||||
|
{
|
||||||
|
SendDestroyEvent();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Avoid processing pending events which quite often would lead to crashes after this.
|
||||||
|
QCoreApplication::removePostedEvents(m_qtWindow);
|
||||||
|
|
||||||
|
// Block signals because the handlers access members of a derived class.
|
||||||
|
m_qtWindow->blockSignals(true);
|
||||||
|
|
||||||
if ( s_capturedWindow == this )
|
if ( s_capturedWindow == this )
|
||||||
s_capturedWindow = NULL;
|
s_capturedWindow = NULL;
|
||||||
@@ -252,17 +270,7 @@ wxWindowQt::~wxWindowQt()
|
|||||||
SetDropTarget(NULL);
|
SetDropTarget(NULL);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Delete only if the qt widget was created or assigned to this base class
|
delete m_qtWindow;
|
||||||
if (m_qtWindow)
|
|
||||||
{
|
|
||||||
wxLogTrace(TRACE_QT_WINDOW, wxT("wxWindow::~wxWindow %s m_qtWindow=%p"), GetName(), m_qtWindow);
|
|
||||||
|
|
||||||
delete m_qtWindow;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
wxLogTrace(TRACE_QT_WINDOW, wxT("wxWindow::~wxWindow %s m_qtWindow is NULL"), GetName());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user