aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2020-06-29 16:28:07 +0200
committerUlf Hermann <ulf.hermann@qt.io>2020-06-29 21:52:03 +0200
commite16c2d3919113104a7233810b64aabbaf364f4fa (patch)
tree0264739e3b3af998d0b06a62ff1f7276b640f214 /src
parent5e12e609692f67f97339d556c9d8e5f50f50aae8 (diff)
QQmlMetaTypeData: Key nameToType by QHashedString
As the new QMultiHash does not store a separate copy of the key for each value, we'd get dangling string references when the "wrong" values were removed. Change-Id: I4ccf6db8bdbf4d38ef393b66b61b285ce763f5c2 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/qml/qml/qqmlmetatype.cpp3
-rw-r--r--src/qml/qml/qqmlmetatypedata_p.h4
2 files changed, 5 insertions, 2 deletions
diff --git a/src/qml/qml/qqmlmetatype.cpp b/src/qml/qml/qqmlmetatype.cpp
index e3b93c4c61..cf51279bda 100644
--- a/src/qml/qml/qqmlmetatype.cpp
+++ b/src/qml/qml/qqmlmetatype.cpp
@@ -1225,7 +1225,8 @@ QQmlType QQmlMetaType::qmlType(const QHashedStringRef &name, const QHashedString
{
const QQmlMetaTypeDataPtr data;
- QQmlMetaTypeData::Names::ConstIterator it = data->nameToType.constFind(name);
+ const QHashedString key(QString::fromRawData(name.constData(), name.length()), name.hash());
+ QQmlMetaTypeData::Names::ConstIterator it = data->nameToType.constFind(key);
while (it != data->nameToType.cend() && it.key() == name) {
QQmlType t(*it);
if (module.isEmpty() || t.availableInVersion(module, version))
diff --git a/src/qml/qml/qqmlmetatypedata_p.h b/src/qml/qml/qqmlmetatypedata_p.h
index a5d919e471..121bf51a72 100644
--- a/src/qml/qml/qqmlmetatypedata_p.h
+++ b/src/qml/qml/qqmlmetatypedata_p.h
@@ -70,8 +70,10 @@ struct QQmlMetaTypeData
QSet<QQmlType> undeletableTypes;
typedef QHash<int, QQmlTypePrivate *> Ids;
Ids idToType;
- typedef QMultiHash<QHashedStringRef, QQmlTypePrivate *> Names;
+
+ using Names = QMultiHash<QHashedString, QQmlTypePrivate *>;
Names nameToType;
+
typedef QHash<QUrl, QQmlTypePrivate *> Files; //For file imported composite types only
Files urlToType;
Files urlToNonFileImportType; // For non-file imported composite and composite