forked from qt-creator/qt-creator
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 <tim.jenssen@qt.io> Reviewed-by: Qt CI Patch Build Bot <ci_patchbuild_bot@qt.io>
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user