From 75f264cc6c47493f26ee81c783d1f9b64310c1d6 Mon Sep 17 00:00:00 2001 From: Leonardo Sobral Cunha Date: Tue, 10 Nov 2009 14:12:59 +0100 Subject: Fixes sub-attaq segfault when pausing The sub-attaq's animation manager was accessing a deleted animation. Task-number: QTBUG-5646 Reviewed-by: thierry --- demos/sub-attaq/animationmanager.cpp | 7 +++++++ demos/sub-attaq/animationmanager.h | 3 +++ 2 files changed, 10 insertions(+) diff --git a/demos/sub-attaq/animationmanager.cpp b/demos/sub-attaq/animationmanager.cpp index eb5a125..b3fc8e1 100644 --- a/demos/sub-attaq/animationmanager.cpp +++ b/demos/sub-attaq/animationmanager.cpp @@ -62,11 +62,18 @@ AnimationManager *AnimationManager::self() void AnimationManager::registerAnimation(QAbstractAnimation *anim) { + QObject::connect(anim, SIGNAL(destroyed(QObject*)), this, SLOT(unregisterAnimation_helper(QObject*))); animations.append(anim); } +void AnimationManager::unregisterAnimation_helper(QObject *obj) +{ + unregisterAnimation(static_cast(obj)); +} + void AnimationManager::unregisterAnimation(QAbstractAnimation *anim) { + QObject::disconnect(anim, SIGNAL(destroyed(QObject*)), this, SLOT(unregisterAnimation_helper(QObject*))); animations.removeAll(anim); } diff --git a/demos/sub-attaq/animationmanager.h b/demos/sub-attaq/animationmanager.h index 8db13eb..48d84d1 100644 --- a/demos/sub-attaq/animationmanager.h +++ b/demos/sub-attaq/animationmanager.h @@ -62,6 +62,9 @@ public slots: void pauseAll(); void resumeAll(); +private slots: + void unregisterAnimation_helper(QObject *obj); + private: static AnimationManager *instance; QList animations; -- cgit v0.12