aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/qml/qqmltypecompiler.cpp
diff options
context:
space:
mode:
authorFabian Kosmale <fabian.kosmale@qt.io>2020-04-24 15:55:23 +0200
committerFabian Kosmale <fabian.kosmale@qt.io>2020-06-22 09:14:36 +0200
commit121b8a6ae42d9423250ab1121c15c49ab064307a (patch)
treeb092dd6514e88ac4d5aff5eed1399142a57384db /src/qml/qml/qqmltypecompiler.cpp
parent8a3f8595569a920cf2fa811704dec97ae31be15d (diff)
qqmltypecompiler: Be more careful when resolving enums
Task-number: QTBUG-83703 Pick-to: 5.15 Change-Id: I60c0811e47e0cd3b63b3ddfebb9bb6e9ab7f4f40 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'src/qml/qml/qqmltypecompiler.cpp')
-rw-r--r--src/qml/qml/qqmltypecompiler.cpp18
1 files changed, 14 insertions, 4 deletions
diff --git a/src/qml/qml/qqmltypecompiler.cpp b/src/qml/qml/qqmltypecompiler.cpp
index a9f5cdbf8d..a49722f57e 100644
--- a/src/qml/qml/qqmltypecompiler.cpp
+++ b/src/qml/qml/qqmltypecompiler.cpp
@@ -616,10 +616,20 @@ bool QQmlEnumTypeResolver::tryQualifiedEnumAssignment(const QmlIR::Object *obj,
bool ok = false;
auto *tr = resolvedType(obj->inheritedTypeNameIndex);
- if (type.isValid() && tr && tr->type() == type) {
- // When these two match, we can short cut the search
- QMetaProperty mprop = propertyCache->firstCppMetaObject()->property(prop->coreIndex());
- QMetaEnum menum = mprop.enumerator();
+
+ // When these two match, we can short cut the search, unless...
+ bool useFastPath = type.isValid() && tr && tr->type() == type;
+ QMetaProperty mprop;
+ QMetaEnum menum;
+ if (useFastPath) {
+ mprop = propertyCache->firstCppMetaObject()->property(prop->coreIndex());
+ menum = mprop.enumerator();
+ // ...the enumerator merely comes from a related metaobject, but the enum scope does not match
+ // the typename we resolved
+ if (!menum.isScoped() && scopedEnumName.isEmpty() && typeName != QString::fromUtf8(menum.scope()))
+ useFastPath = false;;
+ }
+ if (useFastPath) {
QByteArray enumName = enumValue.toUtf8();
if (menum.isScoped() && !scopedEnumName.isEmpty() && enumName != scopedEnumName.toUtf8())
return true;