summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/kernel/qobject/tst_qobject.cpp
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@digia.com>2013-12-09 10:13:48 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-12-09 10:13:48 +0100
commit25b390256bf2a699231a165e49f4100262ed29ac (patch)
tree4c3c3cc8dbbe1a523edb26aefd29c22da8732e1f /tests/auto/corelib/kernel/qobject/tst_qobject.cpp
parentbcf346a76659f896a25f31aa44f64ba5f28ba8e1 (diff)
parentf6dbdd9c16166f345fd5743886229192c97c2c4f (diff)
Merge "Merge remote-tracking branch 'origin/stable' into dev" into refs/staging/dev
Diffstat (limited to 'tests/auto/corelib/kernel/qobject/tst_qobject.cpp')
-rw-r--r--tests/auto/corelib/kernel/qobject/tst_qobject.cpp38
1 files changed, 38 insertions, 0 deletions
diff --git a/tests/auto/corelib/kernel/qobject/tst_qobject.cpp b/tests/auto/corelib/kernel/qobject/tst_qobject.cpp
index 6e8de2721e..c6fb1025ac 100644
--- a/tests/auto/corelib/kernel/qobject/tst_qobject.cpp
+++ b/tests/auto/corelib/kernel/qobject/tst_qobject.cpp
@@ -153,6 +153,7 @@ private slots:
void connectBase();
void qmlConnect();
void exceptions();
+ void noDeclarativeParentChangedOnDestruction();
};
struct QObjectCreatedOnShutdown
@@ -6282,6 +6283,43 @@ void tst_QObject::exceptions()
#endif
}
+#ifdef QT_BUILD_INTERNAL
+static bool parentChangeCalled = false;
+
+static void testParentChanged(QAbstractDeclarativeData *, QObject *, QObject *)
+{
+ parentChangeCalled = true;
+}
+#endif
+
+void tst_QObject::noDeclarativeParentChangedOnDestruction()
+{
+#ifdef QT_BUILD_INTERNAL
+ typedef void (*ParentChangedCallback)(QAbstractDeclarativeData *, QObject *, QObject *);
+ QScopedValueRollback<ParentChangedCallback> rollback(QAbstractDeclarativeData::parentChanged);
+ QAbstractDeclarativeData::parentChanged = testParentChanged;
+
+ QObject *parent = new QObject;
+ QObject *child = new QObject;
+
+ QAbstractDeclarativeData dummy;
+ QObjectPrivate::get(child)->declarativeData = &dummy;
+
+ parentChangeCalled = false;
+ child->setParent(parent);
+
+ QVERIFY(parentChangeCalled);
+ parentChangeCalled = false;
+
+ delete child;
+ QVERIFY(!parentChangeCalled);
+
+ delete parent;
+#else
+ QSKIP("Needs QT_BUILD_INTERNAL");
+#endif
+}
+
// Test for QtPrivate::HasQ_OBJECT_Macro
Q_STATIC_ASSERT(QtPrivate::HasQ_OBJECT_Macro<tst_QObject>::Value);
Q_STATIC_ASSERT(!QtPrivate::HasQ_OBJECT_Macro<SiblingDeleter>::Value);