aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/util/qquickanimation.cpp
diff options
context:
space:
mode:
authorFabian Kosmale <fabian.kosmale@qt.io>2021-08-27 16:37:27 +0200
committerFabian Kosmale <fabian.kosmale@qt.io>2021-09-24 11:32:24 +0200
commit45fae9968d72fc3809051cfa8c3bdd17b937001b (patch)
tree1426927f3150c2c725ca7ed9721aa94467182fd7 /src/quick/util/qquickanimation.cpp
parentedb5a06d1556dcf5ff044a40fbcf5247abe43853 (diff)
QQuickAbstractAnimation: Avoid finalizer callback
We can observe the following: setRunning only installs a finalizer in the case where the component has not completed yet. Therefore, it must already be safe to execute the code in setRunning between componentComplete and the time where the finalizers run. Thus, instead of relying on finalizers, we can simply remember whether we have to do some work, and do it in componentComplete. Change-Id: I07f9c943517e8a9e8d8183743804c9f99488bd45 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Diffstat (limited to 'src/quick/util/qquickanimation.cpp')
-rw-r--r--src/quick/util/qquickanimation.cpp31
1 files changed, 11 insertions, 20 deletions
diff --git a/src/quick/util/qquickanimation.cpp b/src/quick/util/qquickanimation.cpp
index d8ac42f9e6..b629196556 100644
--- a/src/quick/util/qquickanimation.cpp
+++ b/src/quick/util/qquickanimation.cpp
@@ -251,14 +251,8 @@ void QQuickAbstractAnimation::setRunning(bool r)
d->running = r;
if (r == false)
d->avoidPropertyValueSourceStart = true;
- else if (!d->registered) {
- d->registered = true;
- QQmlEnginePrivate *engPriv = QQmlEnginePrivate::get(qmlEngine(this));
- static int finalizedIdx = -1;
- if (finalizedIdx < 0)
- finalizedIdx = metaObject()->indexOfSlot("componentFinalized()");
- engPriv->registerFinalizeCallback(this, finalizedIdx);
- }
+ else if (!d->needsDeferredSetRunning)
+ d->needsDeferredSetRunning = true;
return;
}
@@ -371,18 +365,15 @@ void QQuickAbstractAnimation::componentComplete()
{
Q_D(QQuickAbstractAnimation);
d->componentComplete = true;
-}
-
-void QQuickAbstractAnimation::componentFinalized()
-{
- Q_D(QQuickAbstractAnimation);
- if (d->running) {
- d->running = false;
- setRunning(true);
- }
- if (d->paused) {
- d->paused = false;
- setPaused(true);
+ if (d->needsDeferredSetRunning) {
+ if (d->running) {
+ d->running = false;
+ setRunning(true);
+ }
+ if (d->paused) {
+ d->paused = false;
+ setPaused(true);
+ }
}
}