summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>2023-01-13 14:04:20 +0100
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2023-01-30 09:51:50 +0000
commitf8aac9601dcd3c86b810479c022d07c7e1eb2b86 (patch)
treeee0ae8e06b74ba55bd283ed8fc6765e5fc05e572
parentacd81a50e2464233324e14aa4dd23fc984c6680d (diff)
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>
-rw-r--r--src/compositor/extensions/qwaylandquickshellsurfaceitem.cpp11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/compositor/extensions/qwaylandquickshellsurfaceitem.cpp b/src/compositor/extensions/qwaylandquickshellsurfaceitem.cpp
index 28806f622..dfbe41490 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);
+ }
}
/*