aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/animations
diff options
context:
space:
mode:
Diffstat (limited to 'src/qml/animations')
-rw-r--r--src/qml/animations/qabstractanimationjob.cpp6
-rw-r--r--src/qml/animations/qabstractanimationjob_p.h3
-rw-r--r--src/qml/animations/qanimationjobutil_p.h32
-rw-r--r--src/qml/animations/qcontinuinganimationgroupjob.cpp2
-rw-r--r--src/qml/animations/qparallelanimationgroupjob.cpp2
-rw-r--r--src/qml/animations/qpauseanimationjob.cpp2
-rw-r--r--src/qml/animations/qsequentialanimationgroupjob.cpp2
7 files changed, 33 insertions, 16 deletions
diff --git a/src/qml/animations/qabstractanimationjob.cpp b/src/qml/animations/qabstractanimationjob.cpp
index ece2f0d692..c6ace05b8f 100644
--- a/src/qml/animations/qabstractanimationjob.cpp
+++ b/src/qml/animations/qabstractanimationjob.cpp
@@ -263,7 +263,6 @@ QAbstractAnimationJob::QAbstractAnimationJob()
, m_currentLoopStartTime(0)
, m_nextSibling(nullptr)
, m_previousSibling(nullptr)
- , m_wasDeleted(nullptr)
, m_hasRegisteredTimer(false)
, m_isPause(false)
, m_isGroup(false)
@@ -277,9 +276,6 @@ QAbstractAnimationJob::QAbstractAnimationJob()
QAbstractAnimationJob::~QAbstractAnimationJob()
{
- if (m_wasDeleted)
- *m_wasDeleted = true;
-
//we can't call stop here. Otherwise we get pure virtual calls
if (m_state != Stopped) {
State oldState = m_state;
@@ -645,7 +641,7 @@ void QAbstractAnimationJob::removeAnimationChangeListener(QAnimationJobChangeLis
void QAbstractAnimationJob::debugAnimation(QDebug d) const
{
- d << "AbstractAnimationJob(" << hex << (const void *) this << dec << ") state:"
+ d << "AbstractAnimationJob(" << Qt::hex << (const void *) this << Qt::dec << ") state:"
<< m_state << "duration:" << duration();
}
diff --git a/src/qml/animations/qabstractanimationjob_p.h b/src/qml/animations/qabstractanimationjob_p.h
index 0be6ca96ea..d046ce9def 100644
--- a/src/qml/animations/qabstractanimationjob_p.h
+++ b/src/qml/animations/qabstractanimationjob_p.h
@@ -52,6 +52,7 @@
//
#include <private/qtqmlglobal_p.h>
+#include <private/qanimationjobutil_p.h>
#include <QtCore/QObject>
#include <QtCore/private/qabstractanimation_p.h>
#include <vector>
@@ -130,6 +131,7 @@ public:
bool isRenderThreadJob() const { return m_isRenderThreadJob; }
bool isRenderThreadProxy() const { return m_isRenderThreadProxy; }
+ SelfDeletable m_selfDeletable;
protected:
virtual void updateCurrentTime(int) {}
virtual void updateState(QAbstractAnimationJob::State newState, QAbstractAnimationJob::State oldState);
@@ -174,7 +176,6 @@ protected:
QAbstractAnimationJob *m_previousSibling;
QQmlAnimationTimer *m_timer = nullptr;
- bool *m_wasDeleted;
bool m_hasRegisteredTimer:1;
bool m_isPause:1;
bool m_isGroup:1;
diff --git a/src/qml/animations/qanimationjobutil_p.h b/src/qml/animations/qanimationjobutil_p.h
index e3d6fe9178..83cf3b246f 100644
--- a/src/qml/animations/qanimationjobutil_p.h
+++ b/src/qml/animations/qanimationjobutil_p.h
@@ -51,20 +51,40 @@
// We mean it.
//
+#include <type_traits>
+
QT_REQUIRE_CONFIG(qml_animation);
-#define RETURN_IF_DELETED(func) \
+// SelfDeletable is used for self-destruction detection along with
+// ACTION_IF_DELETED and RETURN_IF_DELETED macros. While using, the objects
+// under test should have a member m_selfDeletable of type SelfDeletable
+struct SelfDeletable {
+ ~SelfDeletable() {
+ if (m_wasDeleted)
+ *m_wasDeleted = true;
+ }
+ bool *m_wasDeleted = nullptr;
+};
+
+// \param p pointer to object under test, which should have a member m_selfDeletable of type SelfDeletable
+// \param func statements or functions that to be executed under test.
+// \param action post process if p was deleted under test.
+#define ACTION_IF_DELETED(p, func, action) \
{ \
- bool *prevWasDeleted = m_wasDeleted; \
+ static_assert(std::is_same<decltype((p)->m_selfDeletable), SelfDeletable>::value, "m_selfDeletable must be SelfDeletable");\
+ bool *prevWasDeleted = (p)->m_selfDeletable.m_wasDeleted; \
bool wasDeleted = false; \
- m_wasDeleted = &wasDeleted; \
- func; \
+ (p)->m_selfDeletable.m_wasDeleted = &wasDeleted; \
+ {func;} \
if (wasDeleted) { \
if (prevWasDeleted) \
*prevWasDeleted = true; \
- return; \
+ {action;} \
} \
- m_wasDeleted = prevWasDeleted; \
+ (p)->m_selfDeletable.m_wasDeleted = prevWasDeleted; \
}
+#define RETURN_IF_DELETED(func) \
+ACTION_IF_DELETED(this, func, return)
+
#endif // QANIMATIONJOBUTIL_P_H
diff --git a/src/qml/animations/qcontinuinganimationgroupjob.cpp b/src/qml/animations/qcontinuinganimationgroupjob.cpp
index 10096bf19c..88c0e9e60e 100644
--- a/src/qml/animations/qcontinuinganimationgroupjob.cpp
+++ b/src/qml/animations/qcontinuinganimationgroupjob.cpp
@@ -120,7 +120,7 @@ void QContinuingAnimationGroupJob::uncontrolledAnimationFinished(QAbstractAnimat
void QContinuingAnimationGroupJob::debugAnimation(QDebug d) const
{
- d << "ContinuingAnimationGroupJob(" << hex << (const void *) this << dec << ")";
+ d << "ContinuingAnimationGroupJob(" << Qt::hex << (const void *) this << Qt::dec << ")";
debugChildren(d);
}
diff --git a/src/qml/animations/qparallelanimationgroupjob.cpp b/src/qml/animations/qparallelanimationgroupjob.cpp
index 700fdf9fd9..420a934ba2 100644
--- a/src/qml/animations/qparallelanimationgroupjob.cpp
+++ b/src/qml/animations/qparallelanimationgroupjob.cpp
@@ -239,7 +239,7 @@ void QParallelAnimationGroupJob::uncontrolledAnimationFinished(QAbstractAnimatio
void QParallelAnimationGroupJob::debugAnimation(QDebug d) const
{
- d << "ParallelAnimationGroupJob(" << hex << (const void *) this << dec << ")";
+ d << "ParallelAnimationGroupJob(" << Qt::hex << (const void *) this << Qt::dec << ")";
debugChildren(d);
}
diff --git a/src/qml/animations/qpauseanimationjob.cpp b/src/qml/animations/qpauseanimationjob.cpp
index 0652ed578b..aac04d2f8d 100644
--- a/src/qml/animations/qpauseanimationjob.cpp
+++ b/src/qml/animations/qpauseanimationjob.cpp
@@ -67,7 +67,7 @@ void QPauseAnimationJob::updateCurrentTime(int)
void QPauseAnimationJob::debugAnimation(QDebug d) const
{
- d << "PauseAnimationJob(" << hex << (const void *) this << dec << ")" << "duration:" << m_duration;
+ d << "PauseAnimationJob(" << Qt::hex << (const void *) this << Qt::dec << ")" << "duration:" << m_duration;
}
QT_END_NAMESPACE
diff --git a/src/qml/animations/qsequentialanimationgroupjob.cpp b/src/qml/animations/qsequentialanimationgroupjob.cpp
index d98546122f..dc57444b32 100644
--- a/src/qml/animations/qsequentialanimationgroupjob.cpp
+++ b/src/qml/animations/qsequentialanimationgroupjob.cpp
@@ -426,7 +426,7 @@ void QSequentialAnimationGroupJob::animationRemoved(QAbstractAnimationJob *anim,
void QSequentialAnimationGroupJob::debugAnimation(QDebug d) const
{
- d << "SequentialAnimationGroupJob(" << hex << (const void *) this << dec << ")" << "currentAnimation:" << (void *)m_currentAnimation;
+ d << "SequentialAnimationGroupJob(" << Qt::hex << (const void *) this << Qt::dec << ")" << "currentAnimation:" << (void *)m_currentAnimation;
debugChildren(d);
}