summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/declarative/qml/qdeclarative.h14
-rw-r--r--src/declarative/qml/qdeclarativeimport.cpp31
-rw-r--r--src/declarative/qml/qdeclarativemetatype.cpp75
-rw-r--r--src/declarative/qml/qdeclarativemetatype_p.h4
-rw-r--r--src/declarative/qml/qdeclarativeprivate.h11
-rw-r--r--src/declarative/qml/qdeclarativescriptparser_p.h2
-rw-r--r--src/declarative/qml/qdeclarativetypeloader.cpp72
-rw-r--r--src/doc/src/declarative/qtdeclarative.qdoc15
-rw-r--r--sync.profile16
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/LocalLast2.qml2
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/MyComponentType.qml5
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/localOrderTest.qml7
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/qmlComponentType.qml4
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp36
14 files changed, 249 insertions, 45 deletions
diff --git a/src/declarative/qml/qdeclarative.h b/src/declarative/qml/qdeclarative.h
index 4f7dcb2b..68fae370 100644
--- a/src/declarative/qml/qdeclarative.h
+++ b/src/declarative/qml/qdeclarative.h
@@ -49,6 +49,7 @@
#include <QtDeclarative/qdeclarativelist.h>
#include <QtCore/qbytearray.h>
+#include <QtCore/qurl.h>
#include <QtCore/qmetaobject.h>
QT_BEGIN_HEADER
@@ -390,6 +391,19 @@ int qmlRegisterCustomType(const char *uri, int versionMajor, int versionMinor,
return QDeclarativePrivate::qmlregister(QDeclarativePrivate::TypeRegistration, &type);
}
+inline int Q_DECLARATIVE_EXPORT qmlRegisterType(const QUrl &url, const char *uri, int versionMajor, int versionMinor, const char *qmlName)
+{
+ QDeclarativePrivate::RegisterComponent type = {
+ url,
+ uri,
+ qmlName,
+ versionMajor,
+ versionMinor
+ };
+
+ return QDeclarativePrivate::qmlregister(QDeclarativePrivate::ComponentRegistration, &type);
+}
+
class QDeclarativeContext;
class QDeclarativeEngine;
Q_DECLARATIVE_EXPORT void qmlExecuteDeferred(QObject *);
diff --git a/src/declarative/qml/qdeclarativeimport.cpp b/src/declarative/qml/qdeclarativeimport.cpp
index 20331786..14e69728 100644
--- a/src/declarative/qml/qdeclarativeimport.cpp
+++ b/src/declarative/qml/qdeclarativeimport.cpp
@@ -441,6 +441,13 @@ bool QDeclarativeImportsPrivate::add(const QDeclarativeDirComponents &qmldircomp
set.insert(prefix,(s=new QDeclarativeImportedNamespace));
}
+ bool appendInstead = false;
+ if (importType == QDeclarativeScriptParser::Import::Implicit) {
+ //Treat same as a File import, but lower precedence
+ appendInstead = true;
+ importType = QDeclarativeScriptParser::Import::File;
+ }
+
QString url = uri;
bool versionFound = false;
if (importType == QDeclarativeScriptParser::Import::Library) {
@@ -511,6 +518,9 @@ bool QDeclarativeImportsPrivate::add(const QDeclarativeDirComponents &qmldircomp
if (QDeclarativeMetaType::isModule(uri.toUtf8(), vmaj, vmin))
versionFound = true;
+ //Load any type->file mappings registered for this uri
+ qmldircomponents << QDeclarativeMetaType::qmlComponents(uri.toUtf8(), vmaj, vmin);
+
if (!versionFound && qmldircomponents.isEmpty()) {
if (errorString) {
bool anyversion = QDeclarativeMetaType::isModule(uri.toUtf8(), -1, -1);
@@ -588,12 +598,21 @@ bool QDeclarativeImportsPrivate::add(const QDeclarativeDirComponents &qmldircomp
}
}
- s->uris.prepend(uri);
- s->urls.prepend(url);
- s->majversions.prepend(vmaj);
- s->minversions.prepend(vmin);
- s->isLibrary.prepend(importType == QDeclarativeScriptParser::Import::Library);
- s->qmlDirComponents.prepend(qmldircomponents);
+ if (appendInstead) {
+ s->uris.append(uri);
+ s->urls.append(url);
+ s->majversions.append(vmaj);
+ s->minversions.append(vmin);
+ s->isLibrary.append(importType == QDeclarativeScriptParser::Import::Library);
+ s->qmlDirComponents.append(qmldircomponents);
+ } else {
+ s->uris.prepend(uri);
+ s->urls.prepend(url);
+ s->majversions.prepend(vmaj);
+ s->minversions.prepend(vmin);
+ s->isLibrary.prepend(importType == QDeclarativeScriptParser::Import::Library);
+ s->qmlDirComponents.prepend(qmldircomponents);
+ }
return true;
}
diff --git a/src/declarative/qml/qdeclarativemetatype.cpp b/src/declarative/qml/qdeclarativemetatype.cpp
index f9ce988c..4a771de9 100644
--- a/src/declarative/qml/qdeclarativemetatype.cpp
+++ b/src/declarative/qml/qdeclarativemetatype.cpp
@@ -54,6 +54,8 @@
#include <QtCore/qmetaobject.h>
#include <QtCore/qbitarray.h>
#include <QtCore/qreadwritelock.h>
+#include <qfileinfo.h>
+#include <qdir.h>
#include <qmetatype.h>
#include <qobjectdefs.h>
#include <qdatetime.h>
@@ -122,6 +124,15 @@ struct QDeclarativeMetaTypeData
Q_GLOBAL_STATIC(QDeclarativeMetaTypeData, metaTypeData)
Q_GLOBAL_STATIC(QReadWriteLock, metaTypeDataLock)
+struct QDeclarativeRegisteredComponentData
+{
+ ~QDeclarativeRegisteredComponentData() {} ;
+ QMap<QByteArray, QDeclarativeDirComponents*> registeredComponents;
+};
+
+Q_GLOBAL_STATIC(QDeclarativeRegisteredComponentData, registeredComponentData)
+Q_GLOBAL_STATIC(QReadWriteLock, registeredComponentDataLock)
+
QDeclarativeMetaTypeData::~QDeclarativeMetaTypeData()
{
for (int i = 0; i < types.count(); ++i)
@@ -667,6 +678,45 @@ int registerType(const QDeclarativePrivate::RegisterType &type)
return index;
}
+int registerComponent(const QDeclarativePrivate::RegisterComponent& data)
+{
+ if (data.typeName) {
+ for (int ii = 0; data.typeName[ii]; ++ii) {
+ if (!isalnum(data.typeName[ii])) {
+ qWarning("qmlRegisterType(): Invalid QML type name \"%s\"", data.typeName);
+ return 0;
+ }
+ }
+ } else {
+ qWarning("qmlRegisterType(): No QML type name for \"%s\"", data.url.toString().toLatin1().constData());
+ return 0;
+ }
+
+ QWriteLocker lock(registeredComponentDataLock());
+ QString path;
+ // Relative paths are relative to application working directory
+ if (data.url.isRelative() || data.url.scheme() == QLatin1String("file")) // Workaround QTBUG-11929
+ path = QUrl::fromLocalFile(QDir::currentPath()+QLatin1String("/")).resolved(data.url).toString();
+ else
+ path = data.url.toString();
+ QDeclarativeRegisteredComponentData *d = registeredComponentData();
+ QDeclarativeDirParser::Component comp(
+ QString::fromUtf8(data.typeName),
+ path,
+ data.majorVersion,
+ data.minorVersion
+ );
+
+ QDeclarativeDirComponents* comps = d->registeredComponents.value(QByteArray(data.uri), 0);
+ if (!comps)
+ d->registeredComponents.insert(QByteArray(data.uri), comps = new QDeclarativeDirComponents);
+
+ // Types added later should take precedence, like registerType
+ comps->prepend(comp);
+
+ return 1;
+}
+
/*
This method is "over generalized" to allow us to (potentially) register more types of things in
the future without adding exported symbols.
@@ -679,6 +729,8 @@ int QDeclarativePrivate::qmlregister(RegistrationType type, void *data)
return registerInterface(*reinterpret_cast<RegisterInterface *>(data));
} else if (type == AutoParentRegistration) {
return registerAutoParentFunction(*reinterpret_cast<RegisterAutoParent *>(data));
+ } else if (type == ComponentRegistration) {
+ return registerComponent(*reinterpret_cast<RegisterComponent *>(data));
}
return -1;
}
@@ -984,6 +1036,29 @@ QDeclarativeType *QDeclarativeMetaType::qmlType(int userType)
}
/*!
+ Returns the component(s) that have been registered for the module specified by \a uri and the version specified
+ by \a version_major and \a version_minor. Returns an empty list if no such components were registered.
+*/
+QDeclarativeDirComponents QDeclarativeMetaType::qmlComponents(const QByteArray &module, int version_major, int version_minor)
+{
+ QReadLocker lock(registeredComponentDataLock());
+ QDeclarativeRegisteredComponentData *data = registeredComponentData();
+
+ QDeclarativeDirComponents* comps = data->registeredComponents.value(module, 0);
+ if (!comps)
+ return QDeclarativeDirComponents();
+ QDeclarativeDirComponents ret = *comps;
+ for (int i = ret.count() - 1; i >= 0; i--) {
+ QDeclarativeDirParser::Component &c = ret[i];
+ if (version_major >= 0 && (c.majorVersion != version_major || c.minorVersion > version_minor))
+ ret.removeAt(i);
+ }
+
+ return ret;
+}
+
+
+/*!
Returns the list of registered QML type names.
*/
QList<QByteArray> QDeclarativeMetaType::qmlTypeNames()
diff --git a/src/declarative/qml/qdeclarativemetatype_p.h b/src/declarative/qml/qdeclarativemetatype_p.h
index d751f049..a1699558 100644
--- a/src/declarative/qml/qdeclarativemetatype_p.h
+++ b/src/declarative/qml/qdeclarativemetatype_p.h
@@ -59,6 +59,7 @@
#include <QtCore/qvariant.h>
#include <QtCore/qbitarray.h>
#include <private/qtdeclarativeglobal_p.h>
+#include <private/qdeclarativedirparser_p.h>
QT_BEGIN_NAMESPACE
@@ -80,6 +81,8 @@ public:
static QDeclarativeType *qmlType(const QMetaObject *metaObject, const QByteArray &module, int version_major, int version_minor);
static QDeclarativeType *qmlType(int);
+ static QDeclarativeDirComponents qmlComponents(const QByteArray& module, int version_major, int version_minor); //### Is this the right place?
+
static QMetaProperty defaultProperty(const QMetaObject *);
static QMetaProperty defaultProperty(QObject *);
static QMetaMethod defaultMethod(const QMetaObject *);
@@ -161,6 +164,7 @@ private:
friend struct QDeclarativeMetaTypeData;
friend int registerType(const QDeclarativePrivate::RegisterType &);
friend int registerInterface(const QDeclarativePrivate::RegisterInterface &);
+ friend int registerComponent(const QDeclarativePrivate::RegisterComponent &);
QDeclarativeType(int, const QDeclarativePrivate::RegisterInterface &);
QDeclarativeType(int, const QDeclarativePrivate::RegisterType &);
~QDeclarativeType();
diff --git a/src/declarative/qml/qdeclarativeprivate.h b/src/declarative/qml/qdeclarativeprivate.h
index db2b0661..b88ff79f 100644
--- a/src/declarative/qml/qdeclarativeprivate.h
+++ b/src/declarative/qml/qdeclarativeprivate.h
@@ -233,10 +233,19 @@ namespace QDeclarativePrivate
AutoParentFunction function;
};
+ struct RegisterComponent {
+ const QUrl &url;
+ const char *uri;
+ const char *typeName;
+ int majorVersion;
+ int minorVersion;
+ };
+
enum RegistrationType {
TypeRegistration = 0,
InterfaceRegistration = 1,
- AutoParentRegistration = 2
+ AutoParentRegistration = 2,
+ ComponentRegistration = 3
};
int Q_DECLARATIVE_EXPORT qmlregister(RegistrationType, void *);
diff --git a/src/declarative/qml/qdeclarativescriptparser_p.h b/src/declarative/qml/qdeclarativescriptparser_p.h
index 671326a2..0d02aba5 100644
--- a/src/declarative/qml/qdeclarativescriptparser_p.h
+++ b/src/declarative/qml/qdeclarativescriptparser_p.h
@@ -75,7 +75,7 @@ public:
public:
Import() : type(Library) {}
- enum Type { Library, File, Script };
+ enum Type { Library, File, Script, Implicit }; //Implicit is only used internally
Type type;
QString uri;
diff --git a/src/declarative/qml/qdeclarativetypeloader.cpp b/src/declarative/qml/qdeclarativetypeloader.cpp
index 012afb39..135bff89 100644
--- a/src/declarative/qml/qdeclarativetypeloader.cpp
+++ b/src/declarative/qml/qdeclarativetypeloader.cpp
@@ -1055,19 +1055,6 @@ void QDeclarativeTypeData::resolveTypes()
QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(m_typeLoader->engine());
QDeclarativeImportDatabase *importDatabase = &ep->importDatabase;
- // For local urls, add an implicit import "." as first (most overridden) lookup.
- // This will also trigger the loading of the qmldir and the import of any native
- // types from available plugins.
- if (QDeclarativeQmldirData *qmldir = qmldirForUrl(finalUrl().resolved(QUrl(QLatin1String("./qmldir"))))) {
- m_imports.addImport(importDatabase, QLatin1String("."),
- QString(), -1, -1, QDeclarativeScriptParser::Import::File,
- qmldir->dirComponents(), 0);
- } else {
- m_imports.addImport(importDatabase, QLatin1String("."),
- QString(), -1, -1, QDeclarativeScriptParser::Import::File,
- QDeclarativeDirComponents(), 0);
- }
-
foreach (const QDeclarativeScriptParser::Import &import, scriptParser.imports()) {
QDeclarativeDirComponents qmldircomponentsnetwork;
if (import.type == QDeclarativeScriptParser::Import::Script)
@@ -1107,6 +1094,7 @@ void QDeclarativeTypeData::resolveTypes()
}
}
+ bool implicitImportLoaded = false;
foreach (QDeclarativeScriptParser::TypeReference *parserRef, scriptParser.referencedTypes()) {
QByteArray typeName = parserRef->name.toUtf8();
@@ -1123,23 +1111,49 @@ void QDeclarativeTypeData::resolveTypes()
// Known to not be a type:
// - known to be a namespace (Namespace {})
// - type with unknown namespace (UnknownNamespace.SomeType {})
- QDeclarativeError error;
- error.setUrl(m_imports.baseUrl());
- QString userTypeName = parserRef->name;
- userTypeName.replace(QLatin1Char('/'),QLatin1Char('.'));
- if (typeNamespace)
- error.setDescription(QDeclarativeTypeLoader::tr("Namespace %1 cannot be used as a type").arg(userTypeName));
- else
- error.setDescription(QDeclarativeTypeLoader::tr("%1 %2").arg(userTypeName).arg(errorString));
-
- if (!parserRef->refObjects.isEmpty()) {
- QDeclarativeParser::Object *obj = parserRef->refObjects.first();
- error.setLine(obj->location.start.line);
- error.setColumn(obj->location.start.column);
+ bool typeFound = false;
+
+ if (!typeNamespace && !implicitImportLoaded) {
+ implicitImportLoaded = true;
+ // For local urls, add an implicit import "." as most overridden lookup.
+ // This will also trigger the loading of the qmldir and the import of any native
+ // types from available plugins.
+ // This is only done if the type is not otherwise found, side effects of plugin loading may be avoided
+ // ### This should be an acceptable variation because A) It's only side effects (and img providers) B) You shouldn't be doing that in "." anyways!
+ if (QDeclarativeQmldirData *qmldir = qmldirForUrl(finalUrl().resolved(QUrl(QLatin1String("./qmldir"))))) {
+ m_imports.addImport(importDatabase, QLatin1String("."),
+ QString(), -1, -1, QDeclarativeScriptParser::Import::Implicit,
+ qmldir->dirComponents(), 0);
+ } else {
+ m_imports.addImport(importDatabase, QLatin1String("."),
+ QString(), -1, -1, QDeclarativeScriptParser::Import::Implicit,
+ QDeclarativeDirComponents(), 0);
+ }
+ if (m_imports.resolveType(typeName, &ref.type, &url, &majorVersion, &minorVersion,
+ &typeNamespace, &errorString) || typeNamespace) {
+ typeFound = true;
+ }
+ }
+
+ if (!typeFound) {
+ QDeclarativeError error;
+ error.setUrl(m_imports.baseUrl());
+ QString userTypeName = parserRef->name;
+ userTypeName.replace(QLatin1Char('/'),QLatin1Char('.'));
+ if (typeNamespace)
+ error.setDescription(QDeclarativeTypeLoader::tr("Namespace %1 cannot be used as a type").arg(userTypeName));
+ else
+ error.setDescription(QDeclarativeTypeLoader::tr("%1 %2").arg(userTypeName).arg(errorString));
+
+ if (!parserRef->refObjects.isEmpty()) {
+ QDeclarativeParser::Object *obj = parserRef->refObjects.first();
+ error.setLine(obj->location.start.line);
+ error.setColumn(obj->location.start.column);
+ }
+
+ setError(error);
+ return;
}
-
- setError(error);
- return;
}
if (ref.type) {
diff --git a/src/doc/src/declarative/qtdeclarative.qdoc b/src/doc/src/declarative/qtdeclarative.qdoc
index 5b43c9a3..0c195a8e 100644
--- a/src/doc/src/declarative/qtdeclarative.qdoc
+++ b/src/doc/src/declarative/qtdeclarative.qdoc
@@ -211,3 +211,18 @@
Returns the QML type id.
*/
+
+/*!
+ \fn int qmlRegisterType(const char *url, const char *uri, int versionMajor, int versionMinor, const char *qmlName);
+ \relates QDeclarativeEngine
+
+ This function registers a type in the QML system with the name \a qmlName, in the library imported from \a uri having the
+ version number composed from \a versionMajor and \a versionMinor. The type is defined by the QML file located at \a url.
+
+ Normally QML files can be loaded as types directly from other QML files, or using a qmldir file. This function allows
+ registration of files to types from a C++ module, such as when the type mapping needs to be procedurally determined at startup.
+
+ #include <QtDeclarative> to use this function.
+
+ Returns non-zero if the registration was sucessful.
+*/
diff --git a/sync.profile b/sync.profile
index 9ad1263a..294aa256 100644
--- a/sync.profile
+++ b/sync.profile
@@ -8,12 +8,12 @@
# - any git symbolic ref resolvable from the module's repository (e.g. "refs/heads/master" to track master branch)
#
%dependencies = (
- "qtbase" => "refs/heads/stable",
- "qtscript" => "refs/heads/stable",
- "qtxmlpatterns" => "refs/heads/stable",
- "qtdeclarative" => "refs/heads/stable",
- "qtjsbackend" => "refs/heads/stable",
- "qtactiveqt" => "refs/heads/stable",
- "qttools" => "refs/heads/stable",
- "qtwebkit" => "refs/heads/stable",
+ "qtbase" => "refs/heads/dev",
+ "qtscript" => "refs/heads/dev",
+ "qtxmlpatterns" => "refs/heads/dev",
+ "qtdeclarative" => "refs/heads/dev",
+ "qtjsbackend" => "refs/heads/dev",
+ "qtactiveqt" => "refs/heads/dev",
+ "qttools" => "refs/heads/dev",
+ "qtwebkit" => "refs/heads/dev",
);
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/LocalLast2.qml b/tests/auto/declarative/qdeclarativelanguage/data/LocalLast2.qml
new file mode 100644
index 00000000..4bf7eb2e
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativelanguage/data/LocalLast2.qml
@@ -0,0 +1,2 @@
+import QtQuick 1.0
+MouseArea {}
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/MyComponentType.qml b/tests/auto/declarative/qdeclarativelanguage/data/MyComponentType.qml
new file mode 100644
index 00000000..9ba0d612
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativelanguage/data/MyComponentType.qml
@@ -0,0 +1,5 @@
+import QtQuick 1.0
+
+Item {
+ property int test: 11
+}
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/localOrderTest.qml b/tests/auto/declarative/qdeclarativelanguage/data/localOrderTest.qml
new file mode 100644
index 00000000..d3b31a3d
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativelanguage/data/localOrderTest.qml
@@ -0,0 +1,7 @@
+import QtQuick 1.0
+import org.qtproject.installedtest 1.0
+
+LocalLast2 {
+ property Item item: LocalLast {}
+}
+
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/qmlComponentType.qml b/tests/auto/declarative/qdeclarativelanguage/data/qmlComponentType.qml
new file mode 100644
index 00000000..532bc319
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativelanguage/data/qmlComponentType.qml
@@ -0,0 +1,4 @@
+import QtQuick 1.0
+import Test 1.0
+
+MyComponentType {}
diff --git a/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp b/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp
index 7443e053..f1467ef6 100644
--- a/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp
+++ b/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp
@@ -99,6 +99,7 @@ private slots:
void assignLiteralToVariant();
void customParserTypes();
void rootAsQmlComponent();
+ void qmlComponentType();
void inlineQmlComponents();
void idProperty();
void autoNotifyConnection();
@@ -132,6 +133,7 @@ private slots:
void reservedWords();
void inlineAssignmentsOverrideBindings();
void nestedComponentRoots();
+ void implicitImportsLast();
void basicRemote_data();
void basicRemote();
@@ -627,6 +629,16 @@ void tst_qdeclarativelanguage::rootAsQmlComponent()
QCOMPARE(object->getChildren()->count(), 2);
}
+// Tests that types can be specified from a QML only component
+void tst_qdeclarativelanguage::qmlComponentType()
+{
+ QDeclarativeComponent component(&engine, testFileUrl("qmlComponentType.qml"));
+ VERIFY_ERRORS(0);
+ QObject *object = qobject_cast<QObject *>(component.create());
+ QVERIFY(object != 0);
+ QCOMPARE(object->property("test"), QVariant(11));
+}
+
// Tests that components can be specified inline
void tst_qdeclarativelanguage::inlineQmlComponents()
{
@@ -1806,6 +1818,11 @@ void tst_qdeclarativelanguage::importsOrder_data()
"LocalLast {}"
<< (!qmlCheckTypes()?"QDeclarativeRectangle":"")// i.e. from org.qtproject.installedtest, not data/LocalLast.qml
<< (!qmlCheckTypes()?"":"LocalLast is ambiguous. Found in lib/org/qtproject/installedtest and in local directory");
+ QTest::newRow("local last 3") <<
+ "import org.qtproject.installedtest 1.0\n"
+ "LocalLast {LocalLast2{}}"
+ << (!qmlCheckTypes()?"QDeclarativeRectangle":"")// i.e. from org.qtproject.installedtest, not data/LocalLast.qml
+ << (!qmlCheckTypes()?"":"LocalLast is ambiguous. Found in lib/org/qtproject/installedtest and in local directory");
}
void tst_qdeclarativelanguage::importsOrder()
@@ -1959,6 +1976,8 @@ void tst_qdeclarativelanguage::initTestCase()
{
QDeclarativeDataTest::initTestCase();
registerTypes();
+ // Registered here because it uses testFileUrl
+ qmlRegisterType(testFileUrl("MyComponentType.qml"), "Test", 1, 0, "MyComponentType");
// Registering the TestType class in other modules should have no adverse effects
qmlRegisterType<TestType>("org.qtproject.TestPre", 1, 0, "Test");
@@ -2021,6 +2040,23 @@ void tst_qdeclarativelanguage::compatibilitySemicolon()
QVERIFY(o != 0);
}
+// Tests that the implicit import has lowest precedence, in the case where
+// there are conflicting types and types only found in the local import.
+// Tests that just check one (or the root) type are in ::importsOrder
+void tst_qdeclarativelanguage::implicitImportsLast()
+{
+ if (qmlCheckTypes())
+ QSKIP("This test is about maintaining the same choice when type is ambiguous.");
+ QDeclarativeComponent component(&engine, testFileUrl("localOrderTest.qml"));
+ VERIFY_ERRORS(0);
+ QObject *object = qobject_cast<QObject *>(component.create());
+ QVERIFY(object != 0);
+ QVERIFY(QString(object->metaObject()->className()).startsWith(QLatin1String("QDeclarativeMouseArea")));
+ QObject* object2 = object->property("item").value<QObject*>();
+ QVERIFY(object2 != 0);
+ QCOMPARE(QString(object2->metaObject()->className()), QLatin1String("QDeclarativeRectangle"));
+}
+
QTEST_MAIN(tst_qdeclarativelanguage)
#include "tst_qdeclarativelanguage.moc"