qt6-bb10/tests/auto/widgets
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
..
dialogs Flatten version-specific blacklisting on macOS to all macOS versions 2020-01-22 17:58:31 +01:00
effects unblacklist passing tests 2019-07-08 11:01:42 +00:00
graphicsview Blacklist failing tests on macOS 10.14 2020-01-30 13:47:27 +00:00
itemviews Blacklist tst_QAbstractItemView::task200665_itemEntered on macOS 2020-01-22 17:26:22 +01:00
kernel widgets: Don't create winId when the widget is being destroyed 2020-02-05 11:05:24 +01:00
styles Blacklist tst_QStyleSheetStyle::widgetStylePropagation on macOS 2020-01-14 00:49:58 +01:00
util Blacklist two tst_QScroller tests on macOS 2020-01-22 17:26:22 +01:00
widgets Flatten version-specific blacklisting on macOS to all macOS versions 2020-01-22 17:58:31 +01:00
widgets.pro Move QGestureRecognizer test to widgets/kernel 2017-06-02 18:36:11 +00:00