diff options
author | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2023-10-18 19:02:08 +0200 |
---|---|---|
committer | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2023-10-21 19:23:12 +0200 |
commit | 70d7c6a937fec04401a3c0bc6380731d9f4478e9 (patch) | |
tree | 17a6a2270293b7e57687753528edf5acc1c0938b /src/gui/kernel/qwindow.cpp | |
parent | 341854a4f36dd7e4afd80c7049a782b39423ff20 (diff) |
Avoid creating child windows twice when already visible
When a child window is made visible without its parent having been
created yet, we defer creating and making the child visible until
the parent is created.
But if a child window is explicitly created, we create the parent
first. And creating the parent will in turn apply visibility to
all children that had their visibility deferred. Which includes
creating the child.
This results in child -> parent -> child creation recursion,
which means that when we return from creating the parent window
we already have a platform window for our child, and should
bail out.
Pick-to: 6.6 6.5
Change-Id: I11dc4864b57f031de2cca70b79cdfc057d4fbd0d
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
Diffstat (limited to 'src/gui/kernel/qwindow.cpp')
-rw-r--r-- | src/gui/kernel/qwindow.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/gui/kernel/qwindow.cpp b/src/gui/kernel/qwindow.cpp index 691bc5c269..ca3e5f274d 100644 --- a/src/gui/kernel/qwindow.cpp +++ b/src/gui/kernel/qwindow.cpp @@ -526,6 +526,13 @@ void QWindowPrivate::create(bool recursive, WId nativeHandle) if (q->parent()) q->parent()->create(); + if (platformWindow) { + // Creating the parent window will end up creating any child window + // that was already visible, via setVisible. If this applies to us, + // we will already have a platform window at this point. + return; + } + // QPlatformWindow will poll geometry() during construction below. Set the // screen here so that high-dpi scaling will use the correct scale factor. if (q->isTopLevel()) { |