diff options
author | Liang Qi <liang.qi@qt.io> | 2019-06-19 13:05:12 +0200 |
---|---|---|
committer | Liang Qi <liang.qi@qt.io> | 2019-06-19 13:05:12 +0200 |
commit | a2d36c9ef566a3e0ec42e297a3d314f134c87da1 (patch) | |
tree | 3cf02240bc190e0ae52c5cb1163e523635e443ab /src/qml/animations | |
parent | 15b90204fa5126f339db551cf7429534f1359322 (diff) | |
parent | e9520ec84c95e10a6826b2289e46552a2d446895 (diff) |
Merge remote-tracking branch 'origin/5.12' into 5.13
Conflicts:
.qmake.conf
src/imports/sharedimage/qsharedimageloader.cpp
src/quick/items/qquickitemviewfxitem_p_p.h
Change-Id: I12ce7c32788f4a394188a934e689b4ebac78138b
Diffstat (limited to 'src/qml/animations')
-rw-r--r-- | src/qml/animations/qabstractanimationjob.cpp | 4 | ||||
-rw-r--r-- | src/qml/animations/qabstractanimationjob_p.h | 3 | ||||
-rw-r--r-- | src/qml/animations/qanimationjobutil_p.h | 32 |
3 files changed, 28 insertions, 11 deletions
diff --git a/src/qml/animations/qabstractanimationjob.cpp b/src/qml/animations/qabstractanimationjob.cpp index ece2f0d692..7a784a2b35 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; 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 |