aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexandru Croitor <alexandru.croitor@qt.io>2022-06-16 17:07:46 +0200
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2022-06-20 07:33:36 +0000
commitba7cc28ee508c3230deccef78ca4952e50380313 (patch)
tree9842c2ee29fc428cefaa161dfd64032b2a5d7f61
parentb0b63b2d9efea014595858662cc30147161ee99e (diff)
Qml: Allow major version of module to be zero
If there is no QML.AddedInVersion then the component should be available from version X.0, with X being the current version of the module. Amends 464abaec05e0aa0ab699243412c50a5d5ac30742 Fixes: QTBUG-104373 Change-Id: If30b66df384fe815c41d2a0b5ca7b034b9955956 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> (cherry picked from commit 9225723a317b8c7e805416592b78aca0ed320049) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r--src/qml/qml/qqml.cpp2
-rw-r--r--tests/auto/qml/qmltyperegistrar/CMakeLists.txt2
-rw-r--r--tests/auto/qml/qmltyperegistrar/VersionZero/CMakeLists.txt20
-rw-r--r--tests/auto/qml/qmltyperegistrar/VersionZero/version_zero_type.h17
-rw-r--r--tests/auto/qml/qmltyperegistrar/tst_qmltyperegistrar.cpp10
-rw-r--r--tests/auto/qml/qmltyperegistrar/tst_qmltyperegistrar.h1
6 files changed, 51 insertions, 1 deletions
diff --git a/src/qml/qml/qqml.cpp b/src/qml/qml/qqml.cpp
index cc15268cc0..2f037548a8 100644
--- a/src/qml/qml/qqml.cpp
+++ b/src/qml/qml/qqml.cpp
@@ -504,7 +504,7 @@ int QQmlPrivate::qmlregister(RegistrationType type, void *data)
const QTypeRevision added = revisionClassInfo(
type.classInfoMetaObject, "QML.AddedInVersion",
- QTypeRevision::fromMinorVersion(0));
+ QTypeRevision::fromVersion(type.version.majorVersion(), 0));
const QTypeRevision removed = revisionClassInfo(
type.classInfoMetaObject, "QML.RemovedInVersion");
const QList<QTypeRevision> furtherRevisions = revisionClassInfos(type.classInfoMetaObject,
diff --git a/tests/auto/qml/qmltyperegistrar/CMakeLists.txt b/tests/auto/qml/qmltyperegistrar/CMakeLists.txt
index 5f6f8e83b2..d1ad5858a5 100644
--- a/tests/auto/qml/qmltyperegistrar/CMakeLists.txt
+++ b/tests/auto/qml/qmltyperegistrar/CMakeLists.txt
@@ -74,3 +74,5 @@ qt_add_qml_module(tst-qmltyperegistrar-with-dashes
foo.cpp foo.h
)
qt_autogen_tools_initial_setup(tst-qmltyperegistrar-with-dashesplugin)
+
+add_subdirectory(VersionZero)
diff --git a/tests/auto/qml/qmltyperegistrar/VersionZero/CMakeLists.txt b/tests/auto/qml/qmltyperegistrar/VersionZero/CMakeLists.txt
new file mode 100644
index 0000000000..09b9cea69a
--- /dev/null
+++ b/tests/auto/qml/qmltyperegistrar/VersionZero/CMakeLists.txt
@@ -0,0 +1,20 @@
+qt_add_library(tst_qmltyperegistrar_major_version_zero)
+qt_autogen_tools_initial_setup(tst_qmltyperegistrar_major_version_zero)
+target_link_libraries(tst_qmltyperegistrar_major_version_zero PRIVATE Qt::Core Qt::Qml)
+qt_enable_autogen_tool(tst_qmltyperegistrar_major_version_zero "moc" ON)
+qt_add_qml_module(tst_qmltyperegistrar_major_version_zero
+ URI VersionZero
+ VERSION 0.1
+ SOURCES
+ version_zero_type.h
+)
+qt_autogen_tools_initial_setup(tst_qmltyperegistrar_major_version_zero)
+
+# Make sure the backing library is found on Windows next to the executable
+set_target_properties(
+ tst_qmltyperegistrar_major_version_zero
+ PROPERTIES
+ RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/..
+ LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/..
+ ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/..
+)
diff --git a/tests/auto/qml/qmltyperegistrar/VersionZero/version_zero_type.h b/tests/auto/qml/qmltyperegistrar/VersionZero/version_zero_type.h
new file mode 100644
index 0000000000..a3277e6ab3
--- /dev/null
+++ b/tests/auto/qml/qmltyperegistrar/VersionZero/version_zero_type.h
@@ -0,0 +1,17 @@
+// Copyright (C) 2022 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+
+#ifndef VERSION_ZERO_TYPE_H
+#define VERSION_ZERO_TYPE_H
+
+#include <QtQml/qqml.h>
+
+class TypeInModuleMajorVersionZero : public QObject
+{
+ Q_OBJECT
+ QML_ELEMENT
+public:
+ TypeInModuleMajorVersionZero(QObject *parent = nullptr) : QObject(parent) {}
+};
+
+#endif // VERSION_ZERO_TYPE_H
diff --git a/tests/auto/qml/qmltyperegistrar/tst_qmltyperegistrar.cpp b/tests/auto/qml/qmltyperegistrar/tst_qmltyperegistrar.cpp
index a8a81dd3cd..e7bf179cfe 100644
--- a/tests/auto/qml/qmltyperegistrar/tst_qmltyperegistrar.cpp
+++ b/tests/auto/qml/qmltyperegistrar/tst_qmltyperegistrar.cpp
@@ -371,4 +371,14 @@ void tst_qmltyperegistrar::foreignRevisionedProperty()
}
#endif
+void tst_qmltyperegistrar::typeInModuleMajorVersionZero()
+{
+ QQmlEngine engine;
+ QQmlComponent c(&engine);
+ c.setData(QStringLiteral("import VersionZero\n"
+ "TypeInModuleMajorVersionZero {}\n").toUtf8(),
+ QUrl(QTest::currentDataTag()));
+ QVERIFY2(c.isReady(), qPrintable(c.errorString()));
+}
+
QTEST_MAIN(tst_qmltyperegistrar)
diff --git a/tests/auto/qml/qmltyperegistrar/tst_qmltyperegistrar.h b/tests/auto/qml/qmltyperegistrar/tst_qmltyperegistrar.h
index dff750f8e8..332293d942 100644
--- a/tests/auto/qml/qmltyperegistrar/tst_qmltyperegistrar.h
+++ b/tests/auto/qml/qmltyperegistrar/tst_qmltyperegistrar.h
@@ -507,6 +507,7 @@ private slots:
void addRemoveVersion_data();
void addRemoveVersion();
+ void typeInModuleMajorVersionZero();
private:
QByteArray qmltypesData;