aboutsummaryrefslogtreecommitdiffstats
path: root/tools/qml/main.cpp
diff options
context:
space:
mode:
authorErik Larsson <erik@ortogonal.com>2014-03-01 07:28:29 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-03-13 21:40:43 +0100
commitf3d8386bcd784c2693d0fcc10f9b621de80f7ae0 (patch)
tree54e76f2ed1acf7310683004cfd7c32167f5a582a /tools/qml/main.cpp
parent5e75ee31289accc1c1ae266b331ccb094319dbf0 (diff)
Fix crash in qml/qmlscene when using dummy-data with imports
When using the tools qml and qmlscene with dummy-data it will crash or behave wrong, due to the dummy-data component will get the state not ready, if the dummy-data qml-files does an import of another folder or a js-file. By changing the way of loading dummy-data, by letting QQmlComponent handle the file opening instead of using the setData() method, qmlscene and qml will be able to handle this type of dummy-data. The tool qml also needed to load the dummy data before loading the regular components, otherwise the dummy-data would not be ready for the other components to use. Task-number: QTBUG-32721 Change-Id: Ia1cc2b2626187e23c7d7313be788202d91b12471 Reviewed-by: Alan Alpert <aalpert@blackberry.com>
Diffstat (limited to 'tools/qml/main.cpp')
-rw-r--r--tools/qml/main.cpp14
1 files changed, 5 insertions, 9 deletions
diff --git a/tools/qml/main.cpp b/tools/qml/main.cpp
index 08095962be..3fa36ad8f7 100644
--- a/tools/qml/main.cpp
+++ b/tools/qml/main.cpp
@@ -351,11 +351,7 @@ static void loadDummyDataFiles(QQmlEngine &engine, const QString& directory)
QStringList list = dir.entryList();
for (int i = 0; i < list.size(); ++i) {
QString qml = list.at(i);
- QFile f(dir.filePath(qml));
- f.open(QIODevice::ReadOnly);
- QByteArray data = f.readAll();
- QQmlComponent comp(&engine);
- comp.setData(data, QUrl());
+ QQmlComponent comp(&engine, dir.filePath(qml));
QObject *dummyData = comp.create();
if (comp.isError()) {
@@ -500,6 +496,10 @@ int main(int argc, char *argv[])
//Load files
LoadWatcher lw(&e, files.count());
+ // Load dummy data before loading QML-files
+ if (!dummyDir.isEmpty() && QFileInfo (dummyDir).isDir())
+ loadDummyDataFiles(e, dummyDir);
+
foreach (const QString &path, files) {
//QUrl::fromUserInput doesn't treat no scheme as relative file paths
QRegularExpression urlRe("[[:word:]]+://.*");
@@ -523,10 +523,6 @@ int main(int argc, char *argv[])
}
}
-
- if (!dummyDir.isEmpty() && QFileInfo (dummyDir).isDir())
- loadDummyDataFiles(e, dummyDir);
-
return app->exec();
}