qt5base-lts/tests/auto/widgets/kernel
VaL Doroshchuk 9ecc595d71 widgets: Don't create winId when the widget is being destroyed
When QWidget is being destroyed, its winId is cleared, and
a QEvent::WinIdChange is sent. If a listener of this event
reacted by calling winId() again, we might crash.

A crash can be observed when this child widget is destroyed in dtor of its parent.
E.g. here is a hierarchy of widgets:
1:QWidget
 2:QObject
 3:QWidget
  4:QWidget

If a listener subscribed for WinIdChange events from (4),
and there is a connection to destroy (4) when (2) is destroyed.

This will lead to infinite loop:

1. QWidget::~QWidget
2. QWidget::destroy
3. QWidgetPrivate::setWinId(0)
4. QCoreApplication::sendEvent(q, QEvent::WinIdChange);
5. eventFilter
6. QWidget::winId
7. QWidgetPrivate::createWinId (this=0x555555957600) at kernel/qwidget.cpp:2380
8. QWidgetPrivate::createWinId (this=0x55555596b040) at kernel/qwidget.cpp:2387
9. QWidget::create (this=0x5555558f2010, window=0, initializeWindow=true, destroyOldWindow=true) at kernel/qwidget.cpp:1163
10. QWidgetPrivate::createWinId (this=0x55555596b040) at kernel/qwidget.cpp:2387
11. QWidget::create (this=0x5555558f2010, window=0, initializeWindow=true, destroyOldWindow=true) at kernel/qwidget.cpp:1163
12. QWidgetPrivate::createWinId (this=0x55555596b040) at kernel/qwidget.cpp:2387

Fixes: QTBUG-81849
Change-Id: Ib4c33ac97d9a79c701431ae107bddfb22720ba0d
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2020-02-05 11:05:24 +01:00
..
qaction tst_QAction(Group): Brush up the tests 2019-06-28 00:24:40 +02:00
qactiongroup tst_QAction(Group): Brush up the tests 2019-06-28 00:24:40 +02:00
qapplication Update for failures only on dev branch. Use general platform names 2019-08-19 18:22:11 +02:00
qboxlayout Remove usages of deprecated APIs of qtbase/widgets 2019-08-01 17:04:13 +00:00
qdesktopwidget Remove usages of deprecated APIs of QDesktopWidget 2019-10-13 13:08:42 +02:00
qformlayout tst_QFormLayout: use QAutoPointer to simplify test and avoid leak 2019-08-13 17:26:11 +02:00
qgesturerecognizer tests: un-blacklist tst_QGestureRecognizer::panGesture on xcb 2018-06-25 13:41:40 +00:00
qgridlayout Remove usages of deprecated APIs of qtbase/widgets 2019-08-01 17:04:13 +00:00
qlayout Remove usages of deprecated APIs of qtbase/widgets 2019-08-01 17:04:13 +00:00
qshortcut Merge remote-tracking branch 'origin/5.13' into 5.14 2019-09-09 07:51:49 +00:00
qsizepolicy Fix tst_QSizePolicy::constExpr() to compile with MSVC 15.8.1 2018-08-30 06:23:51 +00:00
qstackedlayout tests/auto/widgets/kernel: Avoid unconditional qWait()s 2018-04-24 05:01:57 +00:00
qtooltip QToolTip: Don't crash if a tool tip is shown outside screen geometry 2018-10-15 07:44:04 +00:00
qwidget widgets: Don't create winId when the widget is being destroyed 2020-02-05 11:05:24 +01:00
qwidget_window unblacklist passing tests 2019-07-08 11:01:42 +00:00
qwidgetaction testlib: start sharing common helper functions 2017-11-04 20:11:22 +00:00
qwidgetmetatype Finish qmetatype migration to type switcher 2018-10-03 14:48:55 +00:00
qwidgetsvariant Updated license headers 2016-01-21 18:55:18 +00:00
qwindowcontainer winrt: make widgets/kernel auto tests pass 2018-06-22 05:02:45 +00:00
kernel.pro Cleanup widgets/kernel.pro after modularization 2019-03-27 09:29:20 +00:00