From d3a5a72a468ca1a24de21ff2c2387f396a5cd78c Mon Sep 17 00:00:00 2001 From: ivan tkachenko Date: Fri, 16 Sep 2022 01:17:30 +0300 Subject: [PATCH] effects/private: Fix crash when shutting down desktop grid and overview Because of const/non-const issues, iterator got invalidated in the loop, which led to a crash. Cases that trigger it: interaction with a thumbnail while the effect is returning to initial state and shuts down. For example, slightly dragging and releasing a thumbnail such that both TapHandler & DragHandler would react and play each their own transition (yes, it's another bug); or by pressing Escape key while dragging. --- src/libkwineffects/kwinquickeffect.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/libkwineffects/kwinquickeffect.cpp b/src/libkwineffects/kwinquickeffect.cpp index 69b2ceb2df..4bfc370348 100644 --- a/src/libkwineffects/kwinquickeffect.cpp +++ b/src/libkwineffects/kwinquickeffect.cpp @@ -23,7 +23,7 @@ public: { return effect->d.get(); } - bool isItemOnScreen(QQuickItem *item, EffectScreen *screen); + bool isItemOnScreen(QQuickItem *item, EffectScreen *screen) const; SharedQmlEngine::Ptr qmlEngine; std::unique_ptr qmlComponent; @@ -34,13 +34,13 @@ public: std::unique_ptr dummyWindow; }; -bool QuickSceneEffectPrivate::isItemOnScreen(QQuickItem *item, EffectScreen *screen) +bool QuickSceneEffectPrivate::isItemOnScreen(QQuickItem *item, EffectScreen *screen) const { if (!item || !screen || !views.contains(screen)) { return false; } - auto *view = views[screen]; + const QuickSceneView *view = views[screen]; auto *rootItem = view->rootItem(); auto candidate = item->parentItem(); // Is there a more efficient way?