summaryrefslogtreecommitdiffstats
path: root/src/widgets/styles
diff options
context:
space:
mode:
authorChristian Ehrlicher <ch.ehrlicher@gmx.de>2023-10-20 12:45:05 +0200
committerChristian Ehrlicher <ch.ehrlicher@gmx.de>2023-10-21 01:14:52 +0200
commit01eb95acf0b4ae9f750f2245ff3aba43d26bf3f0 (patch)
treefbb54ab6543e844f9588ea69ca7eb6756da2e4b5 /src/widgets/styles
parent4d9d66d7a82d7b4960a377220ffa4ca4428c24c3 (diff)
QCommonStyle: simplify removeAnimation
Simplify removeAnimation by directly passing the pointer to remove to the function instead trying to figure them out later on and relying on QObject::sender(). Change-Id: I9de3a138c60b0da8dd1ab23fe8521798b7f4c13c Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
Diffstat (limited to 'src/widgets/styles')
-rw-r--r--src/widgets/styles/qcommonstyle.cpp17
-rw-r--r--src/widgets/styles/qcommonstyle_p.h2
2 files changed, 8 insertions, 11 deletions
diff --git a/src/widgets/styles/qcommonstyle.cpp b/src/widgets/styles/qcommonstyle.cpp
index 7916609dd7..75518b0719 100644
--- a/src/widgets/styles/qcommonstyle.cpp
+++ b/src/widgets/styles/qcommonstyle.cpp
@@ -1275,11 +1275,11 @@ QStyleAnimation * QCommonStylePrivate::animation(const QObject *target) const
void QCommonStylePrivate::startAnimation(QStyleAnimation *animation) const
{
Q_Q(const QCommonStyle);
- stopAnimation(animation->target());
- QObjectPrivate::connect(animation, &QStyleAnimation::destroyed,
- this, &QCommonStylePrivate::removeAnimation,
- Qt::UniqueConnection);
- animations.insert(animation->target(), animation);
+ const auto target = animation->target();
+ stopAnimation(target);
+ QObject::connect(animation, &QStyleAnimation::destroyed,
+ q, [this, target]() { removeAnimation(target); });
+ animations.insert(target, animation);
animation->start();
}
@@ -1294,12 +1294,9 @@ void QCommonStylePrivate::stopAnimation(const QObject *target) const
}
/*! \internal */
-void QCommonStylePrivate::removeAnimation()
+void QCommonStylePrivate::removeAnimation(const QObject *target) const
{
- Q_Q(QCommonStyle);
- QObject *animation = q->sender();
- if (animation)
- animations.remove(animation->parent());
+ animations.remove(target);
}
#endif
diff --git a/src/widgets/styles/qcommonstyle_p.h b/src/widgets/styles/qcommonstyle_p.h
index b9f32230f9..9d07408e22 100644
--- a/src/widgets/styles/qcommonstyle_p.h
+++ b/src/widgets/styles/qcommonstyle_p.h
@@ -95,7 +95,7 @@ public:
QStyleAnimation* animation(const QObject *target) const;
void startAnimation(QStyleAnimation *animation) const;
void stopAnimation(const QObject *target) const;
- void removeAnimation();
+ void removeAnimation(const QObject *target) const;
private:
mutable QHash<const QObject*, QStyleAnimation*> animations;