diff options
author | Matthew Vogt <matthew.vogt@nokia.com> | 2012-04-27 09:15:11 +1000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-05-04 05:51:29 +0200 |
commit | 186abc1e085e4fae7631e329f44e68a810bca38b (patch) | |
tree | ab4ca7211a2a9f788f8790e52579396762ad4213 /src/qml/qml/qqmldata_p.h | |
parent | 9ae289f259f80458caf7c788ee07357db7e1257a (diff) |
Ensure binding target has not been deleted
Prevent the evaluation of bindings if the target has been deleted.
Also, mark an item as queued for deletion at the beginning of the
destructor call chain, so that bindings triggered by the operation
of the destructor itself are not evaluated (after the context is
destructed, if necessary).
Task-number: QTBUG-25516
Change-Id: I587ef7923eb749eb7980156ad73822c1fb7c1ff3
Reviewed-by: Michael Brasser <michael.brasser@nokia.com>
Diffstat (limited to 'src/qml/qml/qqmldata_p.h')
-rw-r--r-- | src/qml/qml/qqmldata_p.h | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/src/qml/qml/qqmldata_p.h b/src/qml/qml/qqmldata_p.h index e97bbb15dc..4849db0060 100644 --- a/src/qml/qml/qqmldata_p.h +++ b/src/qml/qml/qqmldata_p.h @@ -195,6 +195,10 @@ public: QHash<int, QObject *> *attachedProperties() const; static inline bool wasDeleted(QObject *); + + static void markAsDeleted(QObject *); + static inline void setQueuedForDeletion(QObject *); + private: // For objectNameNotifier and attachedProperties mutable QQmlDataExtended *extendedData; @@ -205,7 +209,7 @@ bool QQmlData::wasDeleted(QObject *object) if (!object) return true; - QObjectPrivate *priv = QObjectPrivate::get(const_cast<QObject *>(object)); + QObjectPrivate *priv = QObjectPrivate::get(object); if (priv->wasDeleted) return true; @@ -213,6 +217,17 @@ bool QQmlData::wasDeleted(QObject *object) static_cast<QQmlData *>(priv->declarativeData)->isQueuedForDeletion; } +void QQmlData::setQueuedForDeletion(QObject *object) +{ + if (object) { + if (QObjectPrivate *priv = QObjectPrivate::get(object)) { + if (!priv->wasDeleted && priv->declarativeData) { + static_cast<QQmlData *>(priv->declarativeData)->isQueuedForDeletion = true; + } + } + } +} + QQmlNotifierEndpoint *QQmlData::notify(int index) { Q_ASSERT(index <= 0xFFFF); |