qt6-bb10/tests/auto/gui/kernel
Giuseppe D'Angelo 9ea1f0f8b9 Fix qobject_cast on partially destroyed QWidget/QWindow
QWidget and QWindow use bits in QObjectPrivate to provide for a couple
of shortcuts -- one in qobject_cast, and another in the isWidgetType() /
isWindowType() functions in QObject. These can be optimized by simply
looking at the bits, without actually doing more expensive runtime
casts.

These bits were set on construction, but not unset on destruction.  The
result was for instance that destroying a QWidget would report that the
object was still a QWidget when ~QObject was reached.

Fix this

1) by setting the bits only when QWidget / QWindow constructors start;

2) by resetting the bits once ~QWidget / ~QWindow are completed.
Technically speaking this is not 100% correct in the presence of data
members, but luckily those classes don't have any.

Amend an existing test for QWidget (whose comment said exactly the
opposite of what the test actually did) and add a test for QWindow.

Some other code was wrongly relying on isWidgetType() returning true
for destroyed QWidgets; amend it as needed.

[ChangeLog][QtCore][QObject] Using qobject_cast on partially constructed
or destroyed QWidget/QWindow instances now yields correct results.
Similarly, using the convenience isWidgetType() / isWindowType()
functions now correctly return false on such instances. Before,
qobject_cast (and the convenience functions) would erroneously report
that a given object was a QWidget (resp. QWindow) even during that
object's construction (before QObject's constructor had completed) or
destruction (after QWidget's (resp. QWindow's) destructors had been
completed). This was semantically wrong and inconsistent with other ways
of gathering runtime type information regarding such an object (e.g.
dynamic_cast, obj->metaObject()->className() and so on).

Pick-to: 6.3
Change-Id: Ic45a887951755a9d1a3b838590f1e9f2c4ae6e92
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2022-01-05 02:47:47 +01:00
..
noqteventloop Allow QWindowsPipe{Reader|Writer} to work with foreign event loops, take 2 2021-03-02 22:53:06 +02:00
qaction Remove the qmake project files 2021-01-07 15:32:28 +01:00
qactiongroup Remove the qmake project files 2021-01-07 15:32:28 +01:00
qaddpostroutine Remove the qmake project files 2021-01-07 15:32:28 +01:00
qbackingstore Fix qt_scrollRectInImage when scrolling outside of the image 2021-12-14 14:11:26 +01:00
qclipboard Compile autotests for Integrity 2021-09-20 17:29:04 +03:00
qcursor Remove the qmake project files 2021-01-07 15:32:28 +01:00
qdrag Remove the qmake project files 2021-01-07 15:32:28 +01:00
qevent Remove the qmake project files 2021-01-07 15:32:28 +01:00
qfileopenevent Fix a few compiler warnings in tests 2021-02-02 12:06:05 +01:00
qguiapplication Decouple quitOnLastWindowClosed from quitLockEnabled 2021-10-18 15:29:09 +02:00
qguieventdispatcher Remove the qmake project files 2021-01-07 15:32:28 +01:00
qguieventloop Remove .prev_CMakeLists.txt files 2021-01-12 20:59:13 +01:00
qguimetatype Remove the qmake project files 2021-01-07 15:32:28 +01:00
qguitimer Remove the qmake project files 2021-01-07 15:32:28 +01:00
qguivariant Remove the qmake project files 2021-01-07 15:32:28 +01:00
qhighdpi High-dpi configuration change testing 2021-09-08 19:01:54 +02:00
qinputdevice Remove the qmake project files 2021-01-07 15:32:28 +01:00
qinputmethod Remove the qmake project files 2021-01-07 15:32:28 +01:00
qkeyevent Android: unblock passing tests 2021-04-27 21:12:50 +03:00
qkeysequence Remove irrelevant test row, fix compiler warning 2021-01-08 16:37:22 +01:00
qmouseevent Revert "Add grabber context pointers" 2021-04-29 16:49:57 +02:00
qmouseevent_modal Remove the qmake project files 2021-01-07 15:32:28 +01:00
qopenglwindow Remove the qmake project files 2021-01-07 15:32:28 +01:00
qpalette Don't change resolve mask when setting brush doesn't change palette 2021-12-03 21:07:09 +01:00
qpixelformat Remove the qmake project files 2021-01-07 15:32:28 +01:00
qrasterwindow Remove the qmake project files 2021-01-07 15:32:28 +01:00
qscreen Remove the qmake project files 2021-01-07 15:32:28 +01:00
qshortcut Make tst_shortcut pass on Wayland 2021-03-11 11:59:14 +01:00
qsurfaceformat Remove the qmake project files 2021-01-07 15:32:28 +01:00
qtouchevent Revert "Add grabber context pointers" 2021-04-29 16:49:57 +02:00
qwindow Fix qobject_cast on partially destroyed QWidget/QWindow 2022-01-05 02:47:47 +01:00
CMakeLists.txt Re-enable tst_qopenglwindow on Linux 2021-12-01 03:28:56 +01:00