aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml
diff options
context:
space:
mode:
authorQt Forward Merge Bot <qt_forward_merge_bot@qt-project.org>2020-03-18 11:44:13 +0100
committerUlf Hermann <ulf.hermann@qt.io>2020-03-18 12:37:04 +0100
commit13caf26b29283b544edc2974fa1ea0481c63b435 (patch)
treec06077293de36f69c42b5e1a38844e2b8bbe07c4 /src/qml
parent36fb7cf832e801a7b3718fa443ec2f1b83e0fea2 (diff)
parent869efe4a49c5286493d7f039325992725bcac6c3 (diff)
Merge remote-tracking branch 'origin/5.15' into dev
Conflicts: tools/qmllint/findunqualified.cpp Change-Id: I2593b5cc0db1d14e0c944aec4b88a80f46f5b0c1
Diffstat (limited to 'src/qml')
-rw-r--r--src/qml/animations/qabstractanimationjob.cpp2
-rw-r--r--src/qml/compiler/qqmlirbuilder.cpp6
-rw-r--r--src/qml/compiler/qqmlirbuilder_p.h1
-rw-r--r--src/qml/qml/qqmlimport.cpp18
-rw-r--r--src/qml/qml/qqmlimport_p.h5
-rw-r--r--src/qml/qml/qqmlvaluetypewrapper.cpp14
6 files changed, 42 insertions, 4 deletions
diff --git a/src/qml/animations/qabstractanimationjob.cpp b/src/qml/animations/qabstractanimationjob.cpp
index c6ace05b8f..82f3e53d68 100644
--- a/src/qml/animations/qabstractanimationjob.cpp
+++ b/src/qml/animations/qabstractanimationjob.cpp
@@ -45,8 +45,6 @@
#include "private/qqmlengine_p.h"
#include "private/qqmlglobal_p.h"
-#define DEFAULT_TIMER_INTERVAL 16
-
QT_BEGIN_NAMESPACE
#ifndef QT_NO_THREAD
diff --git a/src/qml/compiler/qqmlirbuilder.cpp b/src/qml/compiler/qqmlirbuilder.cpp
index 0316e54c09..1f2e59b55e 100644
--- a/src/qml/compiler/qqmlirbuilder.cpp
+++ b/src/qml/compiler/qqmlirbuilder.cpp
@@ -549,6 +549,12 @@ bool IRBuilder::visit(QQmlJS::AST::UiInlineComponent *ast)
recordError(ast->firstSourceLocation(), QLatin1String("Nested inline components are not supported"));
return false;
}
+ if (inlineComponentsNames.contains(ast->name.toString())) {
+ recordError(ast->firstSourceLocation(), QLatin1String("Inline component names must be unique per file"));
+ return false;
+ } else {
+ inlineComponentsNames.insert(ast->name.toString());
+ }
{
QScopedValueRollback<bool> rollBack {insideInlineComponent, true};
if (!defineQMLObject(&idx, ast->component))
diff --git a/src/qml/compiler/qqmlirbuilder_p.h b/src/qml/compiler/qqmlirbuilder_p.h
index 1f2c11f7f3..254d21001b 100644
--- a/src/qml/compiler/qqmlirbuilder_p.h
+++ b/src/qml/compiler/qqmlirbuilder_p.h
@@ -543,6 +543,7 @@ public:
QList<QQmlJS::DiagnosticMessage> errors;
QSet<QString> illegalNames;
+ QSet<QString> inlineComponentsNames;
QList<const QV4::CompiledData::Import *> _imports;
QList<Pragma*> _pragmas;
diff --git a/src/qml/qml/qqmlimport.cpp b/src/qml/qml/qqmlimport.cpp
index 43a9435f83..08e43c1341 100644
--- a/src/qml/qml/qqmlimport.cpp
+++ b/src/qml/qml/qqmlimport.cpp
@@ -1009,6 +1009,12 @@ bool QQmlImportNamespace::resolveType(QQmlTypeLoader *typeLoader, const QHashedS
if (!typeRecursionDetected)
typeRecursionDetected = &localTypeRecursionDetected;
+ if (needsSorting()) {
+ std::stable_sort(imports.begin(), imports.end(), [](QQmlImportInstance *left, QQmlImportInstance *) {
+ return left->isInlineComponent;
+ });
+ setNeedsSorting(false);
+ }
for (int i=0; i<imports.count(); ++i) {
const QQmlImportInstance *import = imports.at(i);
if (import->resolveType(typeLoader, type, version_return, type_return, base,
@@ -1070,6 +1076,17 @@ bool QQmlImportNamespace::resolveType(QQmlTypeLoader *typeLoader, const QHashedS
return false;
}
+bool QQmlImportNamespace::needsSorting() const
+{
+ return nextNamespace == this;
+}
+
+void QQmlImportNamespace::setNeedsSorting(bool needsSorting)
+{
+ Q_ASSERT(nextNamespace == this || nextNamespace == nullptr);
+ nextNamespace = needsSorting ? this : nullptr;
+}
+
QQmlImportsPrivate::QQmlImportsPrivate(QQmlTypeLoader *loader)
: ref(1), typeLoader(loader) {
}
@@ -1782,6 +1799,7 @@ bool QQmlImports::addInlineComponentImport(QQmlImportInstance *const importInsta
importInstance->version = QTypeRevision::zero();
importInstance->containingType = containingType;
d->unqualifiedset.imports.push_back(importInstance);
+ d->unqualifiedset.setNeedsSorting(true);
return true;
}
diff --git a/src/qml/qml/qqmlimport_p.h b/src/qml/qml/qqmlimport_p.h
index 7416bb7a4c..f7f5c32bf4 100644
--- a/src/qml/qml/qqmlimport_p.h
+++ b/src/qml/qml/qqmlimport_p.h
@@ -122,7 +122,12 @@ public:
QHashedString prefix;
// Used by QQmlImportsPrivate::qualifiedSets
+ // set to this in unqualifiedSet to indicate that the lists of imports needs
+ // to be sorted when an inline component import was added
+ // We can't use flag pointer, as that does not work with QFieldList
QQmlImportNamespace *nextNamespace;
+ bool needsSorting() const;
+ void setNeedsSorting(bool needsSorting);
};
class Q_QML_PRIVATE_EXPORT QQmlImports
diff --git a/src/qml/qml/qqmlvaluetypewrapper.cpp b/src/qml/qml/qqmlvaluetypewrapper.cpp
index ba5ba96cbe..aa7e28add0 100644
--- a/src/qml/qml/qqmlvaluetypewrapper.cpp
+++ b/src/qml/qml/qqmlvaluetypewrapper.cpp
@@ -192,7 +192,12 @@ ReturnedValue QQmlValueTypeWrapper::create(ExecutionEngine *engine, QObject *obj
r->d()->object = object;
r->d()->property = property;
r->d()->setPropertyCache(QJSEnginePrivate::get(engine)->cache(metaObject));
- r->d()->setValueType(QQmlValueTypeFactory::valueType(typeId));
+ auto valueType = QQmlValueTypeFactory::valueType(typeId);
+ if (!valueType) {
+ QMetaType metaType(typeId);
+ return engine->throwTypeError(QLatin1String("Type %1 is not a value type").arg(metaType.name()));
+ }
+ r->d()->setValueType(valueType);
r->d()->setGadgetPtr(nullptr);
return r->asReturnedValue();
}
@@ -204,7 +209,12 @@ ReturnedValue QQmlValueTypeWrapper::create(ExecutionEngine *engine, const QVaria
Scoped<QQmlValueTypeWrapper> r(scope, engine->memoryManager->allocate<QQmlValueTypeWrapper>());
r->d()->setPropertyCache(QJSEnginePrivate::get(engine)->cache(metaObject));
- r->d()->setValueType(QQmlValueTypeFactory::valueType(typeId));
+ auto valueType = QQmlValueTypeFactory::valueType(typeId);
+ if (!valueType) {
+ QMetaType metaType(typeId);
+ return engine->throwTypeError(QLatin1String("Type %1 is not a value type").arg(metaType.name()));
+ }
+ r->d()->setValueType(valueType);
r->d()->setGadgetPtr(nullptr);
r->d()->setValue(value);
return r->asReturnedValue();