diff options
| author | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2023-12-22 20:31:48 +0100 |
|---|---|---|
| committer | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2024-01-09 21:01:14 +0100 |
| commit | 2c85fd352f480f77d8727d98b7c02014b6f8ccf6 (patch) | |
| tree | efcbfa5da75fa0e4ad54befab02e48de4abfef1c /src | |
| parent | 768145ffee41a12d2489586b5fe7bc8169272cd0 (diff) | |
WindowContainer: Don't apply visibility to contained window without parent
A Window with a visual parent will not become visible until it inserted
as a child into another window, as otherwise the Window would be shown
as a top level window.
We handle this by listening for ParentWindowChange events, and then
call applyWindowVisibility(), which applies the Window's visible
state.
The reverse is also the case, when the Window loses the parent window,
in which case we get the same ParentWindowChange callback.
In both these cases, the logic for whether to defer showing the
window or not is contained within applyWindowVisibility(), but the
logic was assuming that the visual parent was another item.
That's not always the case, as a Window can have another Window
as its visual parent. In that case we internally parent the child
window to the contents item of the outer Window, but the visual
parent property still reflects the Window.
To solve this, remove the assumption about the visual parent
always being an item. The deferred visibility logic should
apply in all cases, regardless of what type the visual parent
is.
Pick-to: 6.7
Change-Id: I3f7309ac92274ede72f07f350ce2b1ab65234b83
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'src')
| -rw-r--r-- | src/quick/items/qquickwindowmodule.cpp | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/src/quick/items/qquickwindowmodule.cpp b/src/quick/items/qquickwindowmodule.cpp index 52ec658e6f..585b1043ac 100644 --- a/src/quick/items/qquickwindowmodule.cpp +++ b/src/quick/items/qquickwindowmodule.cpp @@ -198,12 +198,11 @@ void QQuickWindowQmlImpl::applyWindowVisibility() if (visible) { if (d->visualParent) { // Even though we're complete, and have a visual parent set, - // that visual parent item may not be part of a window yet. - // Showing this window now would make it a top level, which - // is not what we want. - auto *parentItem = qobject_cast<QQuickItem*>(d->visualParent); - if (parentItem && !QWindow::parent()) { - qCDebug(lcQuickWindow) << "No parent window yet. Deferring."; + // we may not be part of a window yet, or we may have been + // removed from a window that's going away. Showing this window + // now would make it a top level, which is not what we want. + if (!QWindow::parent()) { + qCDebug(lcQuickWindow) << "Waiting for visual parent to reparent us into a window"; // We apply the visibility again on ParentWindowChange return; } |
