diff options
| author | Tarja Sundqvist <tarja.sundqvist@qt.io> | 2025-12-15 16:14:22 +0200 |
|---|---|---|
| committer | Tarja Sundqvist <tarja.sundqvist@qt.io> | 2025-12-15 16:14:22 +0200 |
| commit | b58ec3b086518da5aa573f99426235854c23e35f (patch) | |
| tree | 861a9935d8f1cdba2fdca546836a351736dbddbf /src/qmlcompiler | |
| parent | 4826f86e274f1b29bd769e6790824f9e62a40f62 (diff) | |
| parent | 22032227d16c39211e2ebceef97d21f4d89c7c87 (diff) | |
Merge tag 'v6.5.8-lts-lgpl' into 6.56.5
Qt 6.5.8-lts-lgpl release
Diffstat (limited to 'src/qmlcompiler')
| -rw-r--r-- | src/qmlcompiler/qqmljsimportvisitor.cpp | 6 | ||||
| -rw-r--r-- | src/qmlcompiler/qqmljsscope.cpp | 16 | ||||
| -rw-r--r-- | src/qmlcompiler/qqmljsscope_p.h | 6 | ||||
| -rw-r--r-- | src/qmlcompiler/qqmljstypedescriptionreader.cpp | 7 | ||||
| -rw-r--r-- | src/qmlcompiler/qqmljstyperesolver.cpp | 3 |
5 files changed, 35 insertions, 3 deletions
diff --git a/src/qmlcompiler/qqmljsimportvisitor.cpp b/src/qmlcompiler/qqmljsimportvisitor.cpp index 7db2821a5d..653cc5581e 100644 --- a/src/qmlcompiler/qqmljsimportvisitor.cpp +++ b/src/qmlcompiler/qqmljsimportvisitor.cpp @@ -2139,6 +2139,12 @@ void QQmlJSImportVisitor::endVisit(UiArrayBinding *arrayBinding) const auto propertyName = getScopeName(m_currentScope, QQmlJSScope::QMLScope); leaveEnvironment(); + if (m_currentScope->isInCustomParserParent()) { + // These warnings do not apply for custom parsers and their children and need to be handled + // on a case by case basis + return; + } + qsizetype i = 0; for (auto element = arrayBinding->members; element; element = element->next, ++i) { const auto &type = children[i]; diff --git a/src/qmlcompiler/qqmljsscope.cpp b/src/qmlcompiler/qqmljsscope.cpp index e039c7b386..fcb6fab857 100644 --- a/src/qmlcompiler/qqmljsscope.cpp +++ b/src/qmlcompiler/qqmljsscope.cpp @@ -1201,6 +1201,22 @@ QQmlJSScope::InlineComponentOrDocumentRootName QQmlJSScope::enclosingInlineCompo } /*! + \internal + + Returns true if this type or any base type of it has the "EnforcesScopedEnums" flag. + The rationale is that you can turn on enforcement of scoped enums, but you cannot turn + it off explicitly. + */ +bool QQmlJSScope::enforcesScopedEnums() const +{ + for (const QQmlJSScope *scope = this; scope; scope = scope->baseType().get()) { + if (scope->hasEnforcesScopedEnumsFlag()) + return true; + } + return false; +} + +/*! \internal Returns true if the current type is creatable by checking all the required base classes. "Uncreatability" is only inherited from base types for composite types (in qml) and not for non-composite types (c++). diff --git a/src/qmlcompiler/qqmljsscope_p.h b/src/qmlcompiler/qqmljsscope_p.h index 60c84825de..8dfbebbd06 100644 --- a/src/qmlcompiler/qqmljsscope_p.h +++ b/src/qmlcompiler/qqmljsscope_p.h @@ -82,6 +82,7 @@ public: HasBaseTypeError = 0x100, HasExtensionNamespace = 0x200, IsListProperty = 0x400, + EnforcesScopedEnums = 0x2000, }; Q_DECLARE_FLAGS(Flags, Flag) Q_FLAGS(Flags); @@ -547,6 +548,10 @@ QT_WARNING_POP bool isInlineComponent() const { return m_flags & InlineComponent; } bool isWrappedInImplicitComponent() const { return m_flags & WrappedInImplicitComponent; } bool extensionIsNamespace() const { return m_flags & HasExtensionNamespace; } + + bool enforcesScopedEnums() const; + void setEnforcesScopedEnumsFlag(bool v) { m_flags.setFlag(EnforcesScopedEnums, v); } + void setIsSingleton(bool v) { m_flags.setFlag(Singleton, v); } void setCreatableFlag(bool v) { m_flags.setFlag(Creatable, v); } void setIsComposite(bool v) { m_flags.setFlag(Composite, v); } @@ -725,6 +730,7 @@ private: void addOwnPropertyBindingInQmlIROrder(const QQmlJSMetaPropertyBinding &binding, BindingTargetSpecifier specifier); + bool hasEnforcesScopedEnumsFlag() const { return m_flags & EnforcesScopedEnums; } QHash<QString, JavaScriptIdentifier> m_jsIdentifiers; diff --git a/src/qmlcompiler/qqmljstypedescriptionreader.cpp b/src/qmlcompiler/qqmljstypedescriptionreader.cpp index 381a500b67..ec40f8b14d 100644 --- a/src/qmlcompiler/qqmljstypedescriptionreader.cpp +++ b/src/qmlcompiler/qqmljstypedescriptionreader.cpp @@ -216,6 +216,8 @@ void QQmlJSTypeDescriptionReader::readComponent(UiObjectDefinition *ast) scope->setIsComposite(readBoolBinding(script)); } else if (name == QLatin1String("hasCustomParser")) { scope->setHasCustomParser(readBoolBinding(script)); + } else if (name == QLatin1String("enforcesScopedEnums")) { + scope->setEnforcesScopedEnumsFlag(readBoolBinding(script)); } else if (name == QLatin1String("accessSemantics")) { const QString semantics = readStringBinding(script); if (semantics == QLatin1String("reference")) { @@ -242,8 +244,9 @@ void QQmlJSTypeDescriptionReader::readComponent(UiObjectDefinition *ast) addWarning(script->firstSourceLocation(), tr("Expected only name, prototype, defaultProperty, attachedType, " "valueType, exports, interfaces, isSingleton, isCreatable, " - "isComposite, hasCustomParser, exportMetaObjectRevisions, " - "deferredNames, and immediateNames in script bindings, not \"%1\".") + "isComposite, hasCustomParser, enforcesScopedEnums, " + "exportMetaObjectRevisions, deferredNames, and immediateNames in " + "script bindings, not \"%1\".") .arg(name)); } } else { diff --git a/src/qmlcompiler/qqmljstyperesolver.cpp b/src/qmlcompiler/qqmljstyperesolver.cpp index c7479cff82..3c62009472 100644 --- a/src/qmlcompiler/qqmljstyperesolver.cpp +++ b/src/qmlcompiler/qqmljstyperesolver.cpp @@ -916,7 +916,8 @@ bool QQmlJSTypeResolver::checkEnums(const QQmlJSScope::ConstPtr &scope, const QS return true; } - if (!enumeration.isScoped() && enumeration.hasKey(name)) { + if ((!enumeration.isScoped() || enumeration.isQml() || !scope->enforcesScopedEnums()) + && enumeration.hasKey(name)) { *result = QQmlJSRegisterContent::create( storedType(intType()), enumeration, name, inExtension ? QQmlJSRegisterContent::ExtensionObjectEnum |
