From 6913084b0d649b78dc10b80cd9b8d77d51a50c8b Mon Sep 17 00:00:00 2001 From: Sami Shalayel Date: Fri, 10 Mar 2023 12:07:27 +0100 Subject: 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 --- examples/qml/qmldom/qmldomloadeditwrite.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'examples/qml') 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(), 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) -- cgit v1.2.3