summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@theqtcompany.com>2014-11-24 15:52:42 +0100
committerJani Heikkinen <jani.heikkinen@theqtcompany.com>2014-12-02 09:55:58 +0100
commit64c9cbf3046ca62281aac284271a13f5340f8e21 (patch)
tree62e4b8ad624c408a54244e6c78a4d9337b399ed1
parentca5e643ea9d2878f4a00546ed63a004e10da6ae0 (diff)
downloadqtdeclarative-64c9cbf3046ca62281aac284271a13f5340f8e21.tar.gz
qtdeclarative-64c9cbf3046ca62281aac284271a13f5340f8e21.tar.bz2
qtdeclarative-64c9cbf3046ca62281aac284271a13f5340f8e21.zip
Fix loading of .ui.qml form files with cached compilation units
Simplify the type loading logic and try the Type -> Type.qml and Type -> Type.ui.qml mapping in a simple loop that tries off-disk and cached compilation unit loading. Change-Id: I537feabd0a158a71f330bede9e6988291298ae81 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
-rw-r--r--src/qml/qml/qqmlimport.cpp36
1 files changed, 21 insertions, 15 deletions
diff --git a/src/qml/qml/qqmlimport.cpp b/src/qml/qml/qqmlimport.cpp
index df4006d3c..807eb0536 100644
--- a/src/qml/qml/qqmlimport.cpp
+++ b/src/qml/qml/qqmlimport.cpp
@@ -63,7 +63,8 @@ static const QLatin1Char Backslash('\\');
static const QLatin1Char Colon(':');
static const QLatin1String Slash_qmldir("/qmldir");
static const QLatin1String String_qmldir("qmldir");
-static const QString dotqml_string(QLatin1String(".qml"));
+static const QString dotqml_string(QStringLiteral(".qml"));
+static const QString dotuidotqml_string(QStringLiteral(".ui.qml"));
static bool designerSupportRequired = false;
namespace {
@@ -657,23 +658,28 @@ bool QQmlImportNamespace::Import::resolveType(QQmlTypeLoader *typeLoader,
return (*type_return != 0);
}
} else if (!isLibrary) {
- QString qmlUrl = url + QString::fromRawData(type.constData(), type.length()) + dotqml_string;
-
+ QString qmlUrl;
bool exists = false;
- if (QQmlFile::isBundle(qmlUrl)) {
- exists = QQmlFile::bundleFileExists(qmlUrl, typeLoader->engine());
- } else {
- exists = !typeLoader->absoluteFilePath(QQmlFile::urlToLocalFileOrQrc(qmlUrl)).isEmpty();
- if (!exists) {
- QString formUrl = url + QString::fromRawData(type.constData(), type.length()) + QStringLiteral(".ui.qml");
- if (!typeLoader->absoluteFilePath(QQmlFile::urlToLocalFileOrQrc(formUrl)).isEmpty()) {
- exists = true;
- qmlUrl = formUrl;
- }
+ const QString urlsToTry[2] = {
+ url + QString::fromRawData(type.constData(), type.length()) + dotqml_string, // Type -> Type.qml
+ url + QString::fromRawData(type.constData(), type.length()) + dotuidotqml_string // Type -> Type.ui.qml
+ };
+ for (uint i = 0; i < sizeof(urlsToTry) / sizeof(urlsToTry[0]); ++i) {
+ const QString url = urlsToTry[i];
+
+ if (QQmlFile::isBundle(url)) {
+ exists = QQmlFile::bundleFileExists(url, typeLoader->engine());
+ } else {
+ exists = !typeLoader->absoluteFilePath(QQmlFile::urlToLocalFileOrQrc(url)).isEmpty();
+ if (!exists)
+ exists = QQmlMetaType::findCachedCompilationUnit(QUrl(url));
+ }
+
+ if (exists) {
+ qmlUrl = url;
+ break;
}
- if (!exists)
- exists = QQmlMetaType::findCachedCompilationUnit(QUrl(qmlUrl));
}
if (exists) {