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:
Cătălin Răceanu
2019-03-09 23:16:09 +02:00
committed by Vadim Zeitlin
parent 993334c48a
commit c42bda6bd5

View File

@@ -241,7 +241,25 @@ wxWindowQt::wxWindowQt(wxWindowQt *parent, wxWindowID id, const wxPoint& pos, co
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 )
s_capturedWindow = NULL;
@@ -252,17 +270,7 @@ wxWindowQt::~wxWindowQt()
SetDropTarget(NULL);
#endif
// Delete only if the qt widget was created or assigned to this base class
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());
}
delete m_qtWindow;
}