diff options
-rw-r--r-- | src/qml/qml/qqmltypeloader.cpp | 6 | ||||
-rw-r--r-- | tests/auto/qml/qqmllanguage/data/singleton/+basicSelector/SingletonType.qml | 10 | ||||
-rw-r--r-- | tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp | 20 |
3 files changed, 33 insertions, 3 deletions
diff --git a/src/qml/qml/qqmltypeloader.cpp b/src/qml/qml/qqmltypeloader.cpp index d7ba157f94..eb565babf4 100644 --- a/src/qml/qml/qqmltypeloader.cpp +++ b/src/qml/qml/qqmltypeloader.cpp @@ -1341,7 +1341,7 @@ bool QQmlTypeLoader::Blob::addPragma(const QQmlScript::Pragma &pragma, QList<QQm Q_ASSERT(errors); if (pragma.type == QQmlScript::Pragma::Singleton) { - QUrl myUrl = url(); + QUrl myUrl = finalUrl(); QQmlType *ret = QQmlMetaType::qmlType(myUrl, true); if (!ret) { @@ -1369,7 +1369,7 @@ bool QQmlTypeLoader::Blob::addPragma(const QQmlScript::Pragma &pragma, QList<QQm } else { QQmlError error; error.setDescription(QLatin1String("Invalid pragma")); - error.setUrl(url()); + error.setUrl(finalUrl()); error.setLine(pragma.location.start.line); error.setColumn(pragma.location.start.column); errors->prepend(error); @@ -2086,7 +2086,7 @@ void QQmlTypeData::done() // If the type is CompositeSingleton but there was no pragma Singleton in the // QML file, lets report an error. QQmlType *type = QQmlMetaType::qmlType(url(), true); - if (type && type->isCompositeSingleton() && !m_isSingleton) { + if (!isError() && type && type->isCompositeSingleton() && !m_isSingleton) { QString typeName = type->qmlTypeName(); QQmlError error; diff --git a/tests/auto/qml/qqmllanguage/data/singleton/+basicSelector/SingletonType.qml b/tests/auto/qml/qqmllanguage/data/singleton/+basicSelector/SingletonType.qml new file mode 100644 index 0000000000..3e289aed1a --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/singleton/+basicSelector/SingletonType.qml @@ -0,0 +1,10 @@ +import QtQuick 2.0 +pragma Singleton + +Item { + id: singletonId + + property int testProp1: 625 + property int testProp2: 525 + property int testProp3: 455 +} diff --git a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp index 65afdb06d2..bd66fc88fc 100644 --- a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp +++ b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp @@ -49,6 +49,8 @@ #include <QtCore/qdir.h> #include <QSignalSpy> #include <QFont> +#include <QQmlFileSelector> +#include <QFileSelector> #include <private/qqmlproperty_p.h> #include <private/qqmlmetatype_p.h> @@ -209,6 +211,7 @@ private slots: void compositeSingletonQmlDirError(); void compositeSingletonRemote(); void compositeSingletonJavaScriptPragma(); + void compositeSingletonSelectors(); private: QQmlEngine engine; @@ -3501,6 +3504,23 @@ void tst_qqmllanguage::compositeSingletonJavaScriptPragma() verifyCompositeSingletonPropertyValues(o, "value1", 99, "value2", 333); } +// Reads values from a Singleton accessed through selectors. +void tst_qqmllanguage::compositeSingletonSelectors() +{ + QFileSelector selector; + selector.setExtraSelectors(QStringList() << "basicSelector"); + QQmlFileSelector qmlSelector; + qmlSelector.setSelector(&selector); + QQmlEngine e2; + e2.setUrlInterceptor(&qmlSelector); + QQmlComponent component(&e2, testFile("singletonTest1.qml")); + VERIFY_ERRORS(0); + QObject *o = component.create(); + QVERIFY(o != 0); + + verifyCompositeSingletonPropertyValues(o, "value1", 625, "value2", 455); +} + QTEST_MAIN(tst_qqmllanguage) #include "tst_qqmllanguage.moc" |