diff options
author | Dmitrii Akshintsev <[email protected]> | 2023-12-28 21:31:13 +0100 |
---|---|---|
committer | Dmitrii Akshintsev <[email protected]> | 2024-01-18 11:12:30 +0100 |
commit | bb4391a93e2c50efabf837ac32712057063ce9db (patch) | |
tree | 93833c067ddfbc7356d42ed08213cff6ba1f0f41 /tests/manual/qmldom/qmldomloadeditwrite.cpp | |
parent | a95df6a234e4f6e08975eed71b823d41b98542f6 (diff) |
DOM refactoring. Remove DomItem::loadItem. enable_shared_from_this for DomEnv*
As it was mentioned in the previous commits in the chain one of the
goals of the refactoring is to introduce clearer separation of
concerns.
Only DomTop types are allowed to load files, hence it's arguable
should be reflected in the interfaces explicitly.
With the help of previous commits the relevant pieces of this
function were moved to the corresponding DomEnvironment and DomUniverse
types.
This commit finally removes loadFile from the DomItem API.
*It's also worth noting that in order to minimaze refactoring
efforts and to keep the public API simple (not requiring
DomItem &self argument on the top level), this commit also makes
DomEnvironment a child of the std::enable_shared_from_this.
This somewhat "breaks" the initial design approach inscribed
in the DOM API allowing DomEnvironemt to get a shared_ptr to itself
bypassing corresponding DomItem.ownerAs<> API.
However, in the tradeoff of preserving consistency of the previous
design and the explicitness of the interface, I would value the latter,
hence I find this change acceptable.
Change-Id: Ic2ce3fc80876be6bdbec93e4d273e4c6b7a2b218
Task-number: QTBUG-119550
Reviewed-by: Fabian Kosmale <[email protected]>
Diffstat (limited to 'tests/manual/qmldom/qmldomloadeditwrite.cpp')
-rw-r--r-- | tests/manual/qmldom/qmldomloadeditwrite.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/tests/manual/qmldom/qmldomloadeditwrite.cpp b/tests/manual/qmldom/qmldomloadeditwrite.cpp index 00f07f0662..7f153880a2 100644 --- a/tests/manual/qmldom/qmldomloadeditwrite.cpp +++ b/tests/manual/qmldom/qmldomloadeditwrite.cpp @@ -32,7 +32,7 @@ int main() qDebug() << "Creating an environment loading qml from the directories" << qmltypeDirs; qDebug() << "single threaded, no dependencies"; - DomItem env = + auto envPtr = DomEnvironment::create(qmltypeDirs, QQmlJS::Dom::DomEnvironment::Option::SingleThreaded | QQmlJS::Dom::DomEnvironment::Option::NoDependencies); @@ -42,9 +42,9 @@ int main() // env.loadBuiltins(); qDebug() << "loading the file" << testFilePath; - env.loadFile( + envPtr->loadFile( #if QT_VERSION >= QT_VERSION_CHECK(6, 6, 0) - FileToLoad::fromFileSystem(env.ownerAs<DomEnvironment>(), testFilePath), + FileToLoad::fromFileSystem(envPtr, testFilePath), #else testFilePath, QString(), #endif |