diff options
author | Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io> | 2023-01-13 14:04:20 +0100 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2023-01-30 09:51:50 +0000 |
commit | f8aac9601dcd3c86b810479c022d07c7e1eb2b86 (patch) | |
tree | ee0ae8e06b74ba55bd283ed8fc6765e5fc05e572 /src/compositor/extensions/qwaylandquickshellsurfaceitem.cpp | |
parent | acd81a50e2464233324e14aa4dd23fc984c6680d (diff) | |
download | qtwayland-f8aac9601dcd3c86b810479c022d07c7e1eb2b86.tar.gz |
compositor: Fix crash when raising shell surface item
This was introduced by d89c8920f3b82dd2098971b5a66c4b9c75da5af0.
The raise() function would search for a suitable surface, but
failing to find one, it would search past the end of the
childItems list and cause memory corruption.
[ChangeLog][QtWaylandCompositor] Fixed an issue where the compositor
would sometimes crash if a shell surface item was brought to front.
Fixes: QTBUG-109051
Change-Id: I2249f0881b90fc05b5f0292cd35c6524db4663c5
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
(cherry picked from commit 0088b09e79da01534a703f69dbccbd721e7594d8)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'src/compositor/extensions/qwaylandquickshellsurfaceitem.cpp')
-rw-r--r-- | src/compositor/extensions/qwaylandquickshellsurfaceitem.cpp | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/compositor/extensions/qwaylandquickshellsurfaceitem.cpp b/src/compositor/extensions/qwaylandquickshellsurfaceitem.cpp index 28806f62..dfbe4149 100644 --- a/src/compositor/extensions/qwaylandquickshellsurfaceitem.cpp +++ b/src/compositor/extensions/qwaylandquickshellsurfaceitem.cpp @@ -319,11 +319,14 @@ void QWaylandQuickShellSurfaceItemPrivate::raise() return (!staysOnTop && surf->staysOnTop()) || (staysOnBottom && !surf->staysOnBottom()); return true; // ignore any other Quick items that may be there }; - while (skip(*it)) + auto end = parent->childItems().crend(); + while (it != end && skip(*it)) ++it; - QQuickItem *top = *it; - if (moveItem != top) - moveItem->stackAfter(top); + if (it != end) { + QQuickItem *top = *it; + if (moveItem != top) + moveItem->stackAfter(top); + } } /* |