aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorChris Adams <christopher.adams@nokia.com>2012-05-01 12:11:45 +1000
committerQt by Nokia <qt-info@nokia.com>2012-05-09 00:56:16 +0200
commit029e510256a1a6ea8f30db75fa0745cad01353cb (patch)
treeafee148629983a2490b8ab176dcb050dfc27bd29 /src
parent68b899266ca209d43026376a6cf9d7bbdc3483b8 (diff)
Fix edge case in signal emission semantics
Signal emission triggered by property changes during an onDestruction handler was previously not well tested. This commit adds several unit tests to ensure correct behaviour in that situation. Those unit tests showed a problem in signal emission related to when children objects are cleaned up. This commit also ensures that if such children own their own context, their onDestruction handlers are called prior to marking the child as deleted. Change-Id: Ibf84ae56ba1134e5d6402b742aee1bdc0e5e4e15 Reviewed-by: Matthew Vogt <matthew.vogt@nokia.com>
Diffstat (limited to 'src')
-rw-r--r--src/qml/qml/qqmldata_p.h13
-rw-r--r--src/qml/qml/qqmlengine.cpp14
2 files changed, 15 insertions, 12 deletions
diff --git a/src/qml/qml/qqmldata_p.h b/src/qml/qml/qqmldata_p.h
index 2c2c597de4..12344e3a6b 100644
--- a/src/qml/qml/qqmldata_p.h
+++ b/src/qml/qml/qqmldata_p.h
@@ -193,7 +193,7 @@ public:
static inline bool wasDeleted(QObject *);
static void markAsDeleted(QObject *);
- static inline void setQueuedForDeletion(QObject *);
+ static void setQueuedForDeletion(QObject *);
private:
// For attachedProperties
@@ -213,17 +213,6 @@ 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);
diff --git a/src/qml/qml/qqmlengine.cpp b/src/qml/qml/qqmlengine.cpp
index 22d2845f61..7eed2f9e08 100644
--- a/src/qml/qml/qqmlengine.cpp
+++ b/src/qml/qml/qqmlengine.cpp
@@ -477,6 +477,20 @@ void QQmlData::markAsDeleted(QObject *o)
}
}
+void QQmlData::setQueuedForDeletion(QObject *object)
+{
+ if (object) {
+ if (QObjectPrivate *priv = QObjectPrivate::get(object)) {
+ if (!priv->wasDeleted && priv->declarativeData) {
+ QQmlData *ddata = QQmlData::get(object, false);
+ if (ddata->ownContext && ddata->context)
+ ddata->context->emitDestruction();
+ ddata->isQueuedForDeletion = true;
+ }
+ }
+ }
+}
+
void QQmlEnginePrivate::init()
{
Q_Q(QQmlEngine);