diff options
author | Alan Alpert <aalpert@blackberry.com> | 2013-10-23 15:31:10 -0700 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-11-01 08:06:15 +0100 |
commit | 0d5ef23ee7cf326c080580f145123de7183dc142 (patch) | |
tree | dd9f75dca842bd72c7db39d7a110eea6f4a3acb0 /tools/qml | |
parent | 6ecf0f00ddb68daf55c7a75f88b9807d613a6b85 (diff) |
Fix qml runtime when loading files that imported other files
QQmlComponent::setData does not perform any URL processing. Consequently
when using that function we need to 'normalize' the URLs ourselves to
ensure that the engine finds them acceptable.
Task-number: QTBUG-34301
Change-Id: Ia0f3a51129423020f7e4d7003ca356af3f89b441
Reviewed-by: Antti Piira <apiira@blackberry.com>
Reviewed-by: Shawn Rutledge <shawn.rutledge@digia.com>
Diffstat (limited to 'tools/qml')
-rw-r--r-- | tools/qml/main.cpp | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/tools/qml/main.cpp b/tools/qml/main.cpp index 80b3d11802..4a9cad5568 100644 --- a/tools/qml/main.cpp +++ b/tools/qml/main.cpp @@ -309,14 +309,17 @@ void getAppFlags(int &argc, char **argv) } } -void getFileSansBangLine(const QString &path, QByteArray &output) +bool getFileSansBangLine(const QString &path, QByteArray &output) { QFile f(path); if (!f.open(QFile::ReadOnly | QFile::Text)) - return; + return false; output = f.readAll(); - if (output.startsWith("#!"))//Remove first line in this case (except \n, to avoid disturbing line count) + if (output.startsWith("#!")) {//Remove first line in this case (except \n, to avoid disturbing line count) output.remove(0, output.indexOf('\n')); + return true; + } + return false; } static void loadDummyDataFiles(QQmlEngine &engine, const QString& directory) @@ -479,12 +482,10 @@ int main(int argc, char *argv[]) if (!quietMode) { qDebug() << QObject::tr("qml: loading ") << path; QByteArray strippedFile; - getFileSansBangLine(path, strippedFile); - if (strippedFile.isEmpty()) - // If there's an error opening the file, this will give us the right error message + if (getFileSansBangLine(path, strippedFile)) + e.loadData(strippedFile, e.baseUrl().resolved(QUrl::fromLocalFile(path))); //QQmlComponent won't resolve it for us, it doesn't know it's a valid file if we loadData + else //Errors or no bang line e.load(path); - else - e.loadData(strippedFile, QUrl::fromLocalFile(path)); } else { e.load(path); } |