From 121b8a6ae42d9423250ab1121c15c49ab064307a Mon Sep 17 00:00:00 2001 From: Fabian Kosmale Date: Fri, 24 Apr 2020 15:55:23 +0200 Subject: qqmltypecompiler: Be more careful when resolving enums Task-number: QTBUG-83703 Pick-to: 5.15 Change-Id: I60c0811e47e0cd3b63b3ddfebb9bb6e9ab7f4f40 Reviewed-by: Ulf Hermann --- src/qml/qml/qqmltypecompiler.cpp | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'src/qml/qml/qqmltypecompiler.cpp') 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; -- cgit v1.2.3