From b0835b31fd456c30ea3fcaae6edc58212556477d Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Thu, 21 Aug 2014 13:10:33 +0200 Subject: Fix crash with early QObject property access In the reported bug, it can happen that we try to access the compile-time resolved QObject property of an object that is referenced by id. The binding that uses this is triggered when the property changes but _also_ when the id referenced object gets either created or deleted. The first time the binding is evaluated is very early on, when the id referenced object is not created yet, so the binding evaluation fails. However the dependency is set up, and so later then the id referenced object is created and the id property is set on the context, the notification triggers and the binding is re-evaluated. During that binding evaluation a QObject property access happens by index on an object that doesn't have its VME meta-object set up yet. Therefore the property access fails and a crash occurs or the Q_ASSERT(property) assertion fails. The fix is to set register the id named object in the context _after_ the VME meta-object is setup. Task-number: QTBUG-40018 Change-Id: Ic2d7b4a0c49635efe68e93f2f6c316eb65f0c309 Reviewed-by: Lars Knoll --- tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp') diff --git a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp index 7976987b58..ec931385d5 100644 --- a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp +++ b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp @@ -240,6 +240,8 @@ private slots: void noChildEvents(); + void earlyIdObjectAccess(); + private: QQmlEngine engine; QStringList defaultImportPathList; @@ -3792,6 +3794,14 @@ void tst_qqmllanguage::noChildEvents() QCOMPARE(object->childAddedEventCount(), 0); } +void tst_qqmllanguage::earlyIdObjectAccess() +{ + QQmlComponent component(&engine, testFileUrl("earlyIdObjectAccess.qml")); + QScopedPointer o(component.create()); + QVERIFY(!o.isNull()); + QVERIFY(o->property("success").toBool()); +} + QTEST_MAIN(tst_qqmllanguage) #include "tst_qqmllanguage.moc" -- cgit v1.2.3