diff options
author | Marco Bubke <[email protected]> | 2023-10-04 11:27:55 +0200 |
---|---|---|
committer | Marco Bubke <[email protected]> | 2023-10-04 11:47:41 +0000 |
commit | a88caa00c7da8574b5f8d33ee9625aa4d944966f (patch) | |
tree | 0ec72ed209b30b89870dbee7ad8c435ef75b225f /src | |
parent | a4a8fd5b81f8fd7d06b132c68b6bcfcb78e9f8b8 (diff) |
QmlDesigner: Ensure uniqueness of node meta info
We test for equality by the pointer. To ensure it is uniqueness we now
search for the qualified name. If we get a hit, we use that instance. We
have to add the qualified key too into the cache to make it work.
Change-Id: I7f09203aad5591c41798902a75fc971ece7e1c05
Reviewed-by: Tim Jenssen <[email protected]>
Reviewed-by: Qt CI Patch Build Bot <[email protected]>
Diffstat (limited to 'src')
-rw-r--r-- | src/plugins/qmldesigner/designercore/metainfo/nodemetainfo.cpp | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/src/plugins/qmldesigner/designercore/metainfo/nodemetainfo.cpp b/src/plugins/qmldesigner/designercore/metainfo/nodemetainfo.cpp index af660d538c3..fcb66766797 100644 --- a/src/plugins/qmldesigner/designercore/metainfo/nodemetainfo.cpp +++ b/src/plugins/qmldesigner/designercore/metainfo/nodemetainfo.cpp @@ -719,7 +719,7 @@ PropertyName NodeMetaInfoPrivate::defaultPropertyName() const return PropertyName("data"); } -inline static TypeName stringIdentifier(const TypeName &type, int maj, int min) +static TypeName stringIdentifier(const TypeName &type, int maj, int min) { return type + QByteArray::number(maj) + '_' + QByteArray::number(min); } @@ -729,13 +729,30 @@ std::shared_ptr<NodeMetaInfoPrivate> NodeMetaInfoPrivate::create(Model *model, int major, int minor) { + auto stringfiedType = stringIdentifier(type, major, minor); auto &cache = model->d->nodeMetaInfoCache(); - if (auto found = cache.find(stringIdentifier(type, major, minor)); found != cache.end()) + if (auto found = cache.find(stringfiedType); found != cache.end()) return *found; auto newData = std::make_shared<NodeMetaInfoPrivate>(model, type, major, minor); - if (newData->isValid()) - cache.insert(stringIdentifier(type, major, minor), newData); + + if (!newData->isValid()) + return newData; + + auto stringfiedQualifiedType = stringIdentifier(newData->qualfiedTypeName(), + newData->majorVersion(), + newData->minorVersion()); + + if (auto found = cache.find(stringfiedQualifiedType); found != cache.end()) { + cache.insert(stringfiedType, *found); + return *found; + } + + if (stringfiedQualifiedType != stringfiedType) + cache.insert(stringfiedQualifiedType, newData); + + cache.insert(stringfiedType, newData); + return newData; } |