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.
This commit is contained in:
ivan tkachenko 2022-09-16 01:17:30 +03:00
parent 9897afa55f
commit d3a5a72a46
No known key found for this signature in database
GPG key ID: AF72731B7C654CB3

View file

@ -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<QQmlComponent> qmlComponent;
@ -34,13 +34,13 @@ public:
std::unique_ptr<QWindow> 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?