summaryrefslogtreecommitdiffstats
path: root/tests/auto/declarative/qmlmetaproperty/tst_qmlmetaproperty.cpp
diff options
context:
space:
mode:
authorMichael Brasser <michael.brasser@nokia.com>2010-02-16 03:49:15 (GMT)
committerMichael Brasser <michael.brasser@nokia.com>2010-02-16 04:01:52 (GMT)
commitc37fbe0cbe0ccc0e5991df921aa0c7cf811a3baf (patch)
treea8a20f215f651634ac2cdc554d4cc703fe6f18b5 /tests/auto/declarative/qmlmetaproperty/tst_qmlmetaproperty.cpp
parenta17c34cdddf4bcc619fa660ea520400a1329b34e (diff)
downloadQt-c37fbe0cbe0ccc0e5991df921aa0c7cf811a3baf.zip
Qt-c37fbe0cbe0ccc0e5991df921aa0c7cf811a3baf.tar.gz
Qt-c37fbe0cbe0ccc0e5991df921aa0c7cf811a3baf.tar.bz2
Fix crash in QmlMetaProperty that could occur when using value-type
properties after the engine was deleted.
Diffstat (limited to 'tests/auto/declarative/qmlmetaproperty/tst_qmlmetaproperty.cpp')
-rw-r--r--tests/auto/declarative/qmlmetaproperty/tst_qmlmetaproperty.cpp30
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/auto/declarative/qmlmetaproperty/tst_qmlmetaproperty.cpp b/tests/auto/declarative/qmlmetaproperty/tst_qmlmetaproperty.cpp
index ec6b87f..5c8178f 100644
--- a/tests/auto/declarative/qmlmetaproperty/tst_qmlmetaproperty.cpp
+++ b/tests/auto/declarative/qmlmetaproperty/tst_qmlmetaproperty.cpp
@@ -122,6 +122,9 @@ private slots:
//writeToReadOnly();
+ // Bugs
+ void crashOnValueProperty();
+
private:
QmlEngine engine;
};
@@ -208,6 +211,9 @@ private:
QUrl m_url;
};
+QML_DECLARE_TYPE(PropertyObject);
+QML_DEFINE_TYPE(Test,1,0,PropertyObject,PropertyObject);
+
void tst_qmlmetaproperty::qmlmetaproperty_object()
{
QObject object; // Has no default property
@@ -1118,6 +1124,30 @@ void tst_qmlmetaproperty::writeObjectToQmlList()
QCOMPARE(container->qmlChildren()->at(1), object);
}
+void tst_qmlmetaproperty::crashOnValueProperty()
+{
+ QmlEngine *engine = new QmlEngine;
+ QmlComponent component(engine);
+
+ component.setData("import Test 1.0\nPropertyObject { wrectProperty.x: 10 }", QUrl());
+ PropertyObject *obj = qobject_cast<PropertyObject*>(component.create());
+ QVERIFY(obj != 0);
+
+ QmlMetaProperty p = QmlMetaProperty::createProperty(obj, "wrectProperty.x", qmlContext(obj));
+ QCOMPARE(p.name(), QString("wrectProperty.x"));
+
+ QCOMPARE(p.read(), QVariant(10));
+
+ //don't crash once the engine is deleted
+ delete engine;
+ engine = 0;
+
+ QCOMPARE(p.propertyTypeName(), "int");
+ QCOMPARE(p.read(), QVariant(10));
+ p.write(QVariant(20));
+ QCOMPARE(p.read(), QVariant(20));
+}
+
QTEST_MAIN(tst_qmlmetaproperty)
#include "tst_qmlmetaproperty.moc"