aboutsummaryrefslogtreecommitdiffstats
path: root/examples/qml
diff options
context:
space:
mode:
authorSami Shalayel <sami.shalayel@qt.io>2023-03-10 12:07:27 +0100
committerSami Shalayel <sami.shalayel@qt.io>2023-03-29 19:07:25 +0200
commit6913084b0d649b78dc10b80cd9b8d77d51a50c8b (patch)
tree9eb887e161ed877e61b26ad9f15d83753712fc5f /examples/qml
parent7ad7eb606a0831568dc55c782d1a7cdc8fb395b3 (diff)
Remove DomItem::loadFile code-duplication and use correct environments
The loadFile overload (in DomItem, DomEnvironment and DomUnivers) for different files (in-memory files and files that needs to be loaded from disk) are either copypasted or just calling the other overload. Encapsulate the file-related arguments of all loadFile overloads into a new struct called FileToLoad, such that the copypasted overloads can be removed. Use the static factory function FileToLoad::fromMemory and FileToLoad::fromFileSystem to create the FileToLoad struct. In addition, FileToLoad allows to specify the environment in which a file should be loaded. Prior this commit, myEnv.loadFile() was creating a new environment for each loaded file. Change-Id: I3b6acb681cb77faefdaa447d985bdfbe4f6a9ce2 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'examples/qml')
-rw-r--r--examples/qml/qmldom/qmldomloadeditwrite.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/examples/qml/qmldom/qmldomloadeditwrite.cpp b/examples/qml/qmldom/qmldomloadeditwrite.cpp
index 68a6b993f3..00f07f0662 100644
--- a/examples/qml/qmldom/qmldomloadeditwrite.cpp
+++ b/examples/qml/qmldom/qmldomloadeditwrite.cpp
@@ -43,7 +43,11 @@ int main()
qDebug() << "loading the file" << testFilePath;
env.loadFile(
+#if QT_VERSION >= QT_VERSION_CHECK(6, 6, 0)
+ FileToLoad::fromFileSystem(env.ownerAs<DomEnvironment>(), testFilePath),
+#else
testFilePath, QString(),
+#endif
[&tFile](Path, const DomItem &, const DomItem &newIt) {
tFile = newIt; // callback called when everything is loaded that receives the loaded
// external file pair (path, oldValue, newValue)