qt6-bb10/tests/auto
Tor Arne Vestbø c956eb8edd Reparent QWindow children when reparenting QWidget
When a QWidget was reparented, we would take care to reparent its
backing QWidgetWindow as well, into the nearest QWindow of the
new QWidget parent.

However we would only do this for the reparented widget itself,
and not any of its child widgets. In the case where the widget
has native children with their own QWindows, the widget itself
may not (yet) be native, e.g. if it hasn't been shown yet, or
if the user has set Qt::WA_DontCreateNativeAncestors.

In these scenarios, we would be left with dangling QWindows,
still hanging off their original QWindow parents, which
would eventually lead to crashes.

We now reparent both the QWindow of the reparented widget (as
long as it's not about to be destroyed), and any QQWindow
children we can reach. For each child hierarchy we can stop
once we reach a QWindow, as the QWindow children of that
window will follow along once we reparent the QWindow.

QWindowContainer widgets don't usually have their own
windowHandle(), but still manage a QWindow inside their
parent widget hierarchy. These will not be reparented
during QWidgetPrivate::setParent_sys(), but instead
do their own reparenting later in QWidget::setParent
via QWindowContainer::parentWasChanged(). The only
exception to this is when the top level is about to
be destroyed, in which case we let the window container
know during QWidgetPrivate::setParent_sys().

Finally, although there should not be any leftover
QWindows in the reparented widget once we have done
the QWidgetWindow and QWindowContainer reparenting,
we still do a pass over any remaining QWindows and
reparent those too, since the original code included
this as a possibility.

We could make further improvements in this areas, such
as moving the QWindowContainer::parentWasChanged() call,
but the goal was to keep this change as minimal as possible
so we can back-port it.

Fixes: QTBUG-122747
Pick-to: 6.7.0 6.7 6.6 6.5
Change-Id: I4d1217fce4c3c48cf5f7bfbe9d561ab408ceebb2
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2024-03-14 13:50:36 +00:00
..
bic/data Add binary compatibility file for 6.6.0 2023-10-17 22:23:42 +03:00
cmake "Simplify" versionless targets 2024-03-12 20:27:42 +01:00
concurrent Correct license for tools files 2024-03-05 12:59:21 +01:00
corelib Port two tests' QAbstractEventDispatcher overrides to V2 2024-03-13 17:29:13 -08:00
dbus Remove extra semi-colons 2024-02-06 20:17:18 +09:00
gui rhi: Add basic support for specifying a view format for a texture 2024-03-12 20:27:42 +01:00
guiapplauncher Turn the "concentriccircles" example into snippets, update screenshot 2023-12-14 20:06:32 +01:00
network tst_QHostInfo: increase the timeout to 15s 2024-03-13 18:29:12 -07:00
opengl
other tst_toolsupport: make the i386 case really about i386 2024-03-06 11:09:16 +01:00
printsupport Change license for tests files 2024-02-04 09:56:42 +01:00
shared Change license for tests files 2024-02-04 09:56:42 +01:00
sql CMake: Make a few more auto tests standalone 2024-03-14 01:14:18 +01:00
testlib Port two tests' QAbstractEventDispatcher overrides to V2 2024-03-13 17:29:13 -08:00
tools Long live QT_TECH_PREVIEW_API 2024-02-20 05:01:09 +01:00
wasm CMake: Make a few more auto tests standalone 2024-03-14 01:14:18 +01:00
widgets Reparent QWindow children when reparenting QWidget 2024-03-14 13:50:36 +00:00
xml QtXml: fix leak in QDomText::splitText 2024-03-02 21:22:53 +01:00
CMakeLists.txt wasm: Add auto test corelib/io/qabstractfileengine 2024-02-23 19:11:05 +01:00
network-settings.h Change license for tests files 2024-02-04 09:56:42 +01:00