diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2020-07-14 10:19:16 +0200 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@qt.io> | 2020-07-16 16:25:23 +0200 |
commit | c0f4442ae0d83e63fc90f1d5058081355f83b701 (patch) | |
tree | 49808334a7e6afb02b4a25259db4a3f1af02b83d /tests/auto/qml/qmltyperegistrar | |
parent | f5ef090960f82f53318ca0fd15331bb7ef394366 (diff) |
Restrict qmlRegisterTypesAndRevisions to major version given
We should not register any revisions larger than the given major version
as that allows importing an incomplete module, as the version-less
import. Typically the offending version is pulled in via some
QML_FOREIGN and only the types derived from that foreign class are
available in the higher major version.
Change-Id: I186fb010d704bea514cefff9f66eb58186df5c91
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'tests/auto/qml/qmltyperegistrar')
-rw-r--r-- | tests/auto/qml/qmltyperegistrar/tst_qmltyperegistrar.cpp | 7 | ||||
-rw-r--r-- | tests/auto/qml/qmltyperegistrar/tst_qmltyperegistrar.h | 27 |
2 files changed, 34 insertions, 0 deletions
diff --git a/tests/auto/qml/qmltyperegistrar/tst_qmltyperegistrar.cpp b/tests/auto/qml/qmltyperegistrar/tst_qmltyperegistrar.cpp index 5b468e7b9f..daaa00654e 100644 --- a/tests/auto/qml/qmltyperegistrar/tst_qmltyperegistrar.cpp +++ b/tests/auto/qml/qmltyperegistrar/tst_qmltyperegistrar.cpp @@ -92,4 +92,11 @@ void tst_qmltyperegistrar::isQProperty() QVERIFY(qmltypesData.contains("Property { name: \"someProperty\"; isQProperty: true; type: \"int\" }")); } +void tst_qmltyperegistrar::restrictToImportVersion() +{ + QVERIFY(qmltypesData.contains("ExcessiveVersion")); + QVERIFY(!qmltypesData.contains("1536")); // Q_REVISION(6, 0) + QVERIFY(!qmltypesData.contains("paletteChanged")); // Added in version 6.0 +} + QTEST_MAIN(tst_qmltyperegistrar) diff --git a/tests/auto/qml/qmltyperegistrar/tst_qmltyperegistrar.h b/tests/auto/qml/qmltyperegistrar/tst_qmltyperegistrar.h index 840a22658c..c85ae0dae8 100644 --- a/tests/auto/qml/qmltyperegistrar/tst_qmltyperegistrar.h +++ b/tests/auto/qml/qmltyperegistrar/tst_qmltyperegistrar.h @@ -34,6 +34,32 @@ #include <QtQml/qqml.h> #include <QtCore/qproperty.h> +class ExcessiveVersion : public QObject +{ + Q_OBJECT + QML_ELEMENT + Q_PROPERTY(int palette READ palette WRITE setPalette NOTIFY paletteChanged REVISION(6, 0)) + +public: + int palette() const { return m_palette; } + + + void setPalette(int palette) + { + if (m_palette == palette) + return; + + m_palette = palette; + emit paletteChanged(); + } + +signals: + Q_REVISION(6, 0) void paletteChanged(); + +private: + int m_palette = 0; +}; + class SizeEnums { Q_GADGET @@ -94,6 +120,7 @@ private slots: void superAndForeignTypes(); void accessSemantics(); void isQProperty(); + void restrictToImportVersion(); private: QByteArray qmltypesData; |