Details
-
Bug
-
Resolution: Done
-
P2: Important
-
5.6.0
-
None
-
6a84a51611f69f3641ae47bbd7b6bd5266ae88ef ce37467acf34edf1380f896a0942b616dc4cbead
Description
The destruction sequence of top-level QWidgets results on QWidgetWindow sending an event to its widget while it's running ~QObject(), and therefore after it has run ~QWidget(). The sequence is (omitting a few calls):
~QWidget() --> ~QObject() --> ~QWidgetPrivate() --> QWidgetPrivate::deleteTLSysExtra() --> QWindow::destroy() --> QWidgetWindow::event()
This results in two issues. First, QWidgetWindow expects its widget to be a QWidget after ~QWidget() has been called. Second, any event filter or QApplication::notify() override has to deal with a QObject being deleted without having a way of checking that (as an example, trying to instantiate a QPointer with that object will cause an immediate assert failure).