aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qqmlcomponent
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/qml/qqmlcomponent')
-rw-r--r--tests/auto/qml/qqmlcomponent/data/createParentReference.qml12
-rw-r--r--tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp32
2 files changed, 44 insertions, 0 deletions
diff --git a/tests/auto/qml/qqmlcomponent/data/createParentReference.qml b/tests/auto/qml/qqmlcomponent/data/createParentReference.qml
new file mode 100644
index 0000000000..daa5d3c167
--- /dev/null
+++ b/tests/auto/qml/qqmlcomponent/data/createParentReference.qml
@@ -0,0 +1,12 @@
+import QtQuick 2.0
+
+Item {
+ id: root
+ width: 100
+ height: 100
+
+ function createChild() {
+ Qt.createQmlObject("import QtQuick 2.0;" +
+ "Item { width: parent.width; }", root);
+ }
+}
diff --git a/tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp b/tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp
index d277952f22..603c091a03 100644
--- a/tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp
+++ b/tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp
@@ -71,6 +71,7 @@ private slots:
void qmlCreateObject();
void qmlCreateObjectWithProperties();
void qmlIncubateObject();
+ void qmlCreateParentReference();
private:
QQmlEngine engine;
@@ -181,6 +182,37 @@ void tst_qqmlcomponent::qmlCreateObjectWithProperties()
delete testBindingThisObj;
}
+static QStringList warnings;
+static void msgHandler(QtMsgType, const char *warning)
+{
+ warnings << QString::fromUtf8(warning);
+}
+
+void tst_qqmlcomponent::qmlCreateParentReference()
+{
+ QQmlEngine engine;
+
+ QCOMPARE(engine.outputWarningsToStandardError(), true);
+
+ warnings.clear();
+ QtMsgHandler old = qInstallMsgHandler(msgHandler);
+
+ QQmlComponent component(&engine, testFileUrl("createParentReference.qml"));
+ QVERIFY2(component.errorString().isEmpty(), component.errorString().toUtf8());
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QVERIFY(QMetaObject::invokeMethod(object, "createChild"));
+ delete object;
+
+ qInstallMsgHandler(old);
+
+ engine.setOutputWarningsToStandardError(false);
+ QCOMPARE(engine.outputWarningsToStandardError(), false);
+
+ QCOMPARE(warnings.count(), 0);
+}
+
QTEST_MAIN(tst_qqmlcomponent)
#include "tst_qqmlcomponent.moc"