Fix crash when writing property after engine deletion
authorChris Adams <christopher.adams@nokia.com>
Mon, 12 Mar 2012 01:54:11 +0000 (11:54 +1000)
committerQt by Nokia <qt-info@nokia.com>
Tue, 13 Mar 2012 04:13:50 +0000 (05:13 +0100)
Previously, the engine pointer stored in a QQmlProperty could be
stale due to engine deletion.  This commit ensures we guard that
pointer.

Also reverts cbb7f8b10e99fad675839d7625d3236ed67b3e01

Task-number: QTBUG-24734
Change-Id: I5349c51fbd19fa46a8710280173c1d224358b96e
Reviewed-by: Michael Brasser <michael.brasser@nokia.com>
src/qml/qml/qqmlproperty_p.h
tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp

index 0f97a63..dc02355 100644 (file)
@@ -54,6 +54,7 @@
 //
 
 #include "qqmlproperty.h"
+#include "qqmlengine.h"
 
 #include <private/qobject_p.h>
 #include <private/qtqmlglobal_p.h>
@@ -77,7 +78,7 @@ public:
     Q_DECLARE_FLAGS(WriteFlags, WriteFlag)
 
     QQmlContextData *context;
-    QQmlEngine *engine;
+    QQmlGuard<QQmlEngine> engine;
     QQmlGuard<QObject> object;
 
     QQmlPropertyData core;
index 13ea1ab..ae30090 100644 (file)
@@ -1553,8 +1553,6 @@ void tst_qqmlproperty::crashOnValueProperty()
     delete engine;
     engine = 0;
 
-    QSKIP("QTBUG-24734: test accesses deleted QML engine from QQmlProperty::propertyTypeName()");
-
     QCOMPARE(p.propertyTypeName(), "int");
     QCOMPARE(p.read(), QVariant(10));
     p.write(QVariant(20));