aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2022-02-23 12:17:44 +0100
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2022-02-24 11:16:48 +0000
commit2171d542acd8eea32962d1b24aef67d5df75a396 (patch)
tree1dcf481a267656a88f2b7add43258ec7bdb49231 /tests
parent9b48322f729aac3569973b76594699a52731d62f (diff)
QQmlMetaType: Don't duplicate notify signals for extended types
We have to add the methods first, so that the properties can be associated with their proper notification signals once we add them. If we add the properties first, the "missing" notification signals are synthesized. Fixes: QTBUG-101155 Change-Id: I1aacbf33a24f7a98d05dece77c804bd7cba8a041 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> (cherry picked from commit 57614680f760068c1db39888beba46944f409ff0) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qml/qqmllanguage/data/foreignExtended.qml7
-rw-r--r--tests/auto/qml/qqmllanguage/testtypes.h14
-rw-r--r--tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp11
3 files changed, 29 insertions, 3 deletions
diff --git a/tests/auto/qml/qqmllanguage/data/foreignExtended.qml b/tests/auto/qml/qqmllanguage/data/foreignExtended.qml
index 4863e0d567..b01af6d229 100644
--- a/tests/auto/qml/qqmllanguage/data/foreignExtended.qml
+++ b/tests/auto/qml/qqmllanguage/data/foreignExtended.qml
@@ -5,12 +5,17 @@ QtObject {
property Foreign foreign: Foreign {
objectName: "foreign"
}
- property Extended extended: Extended {}
+ property Extended extended: Extended {
+ objectName: "extended"
+ property int changeCount: 0
+ onExtensionChanged: ++changeCount
+ }
property ForeignExtended foreignExtended: ForeignExtended {
objectName: "foreignExtended"
}
property int extendedBase: extended.base
+ property int extendedChangeCount: extended.changeCount
property int extendedInvokable: extended.invokable()
property int extendedSlot: extended.slot()
diff --git a/tests/auto/qml/qqmllanguage/testtypes.h b/tests/auto/qml/qqmllanguage/testtypes.h
index 06554ef87a..cfc0ad6e71 100644
--- a/tests/auto/qml/qqmllanguage/testtypes.h
+++ b/tests/auto/qml/qqmllanguage/testtypes.h
@@ -1470,13 +1470,23 @@ public:
class Extension : public QObject
{
Q_OBJECT
- Q_PROPERTY(int extension READ extension CONSTANT)
+ Q_PROPERTY(int extension READ extension WRITE setExtension NOTIFY extensionChanged FINAL)
public:
Extension(QObject *parent = nullptr) : QObject(parent) {}
- int extension() const { return 42; }
+ int extension() const { return ext; }
+ void setExtension(int e) {
+ if (e != ext) {
+ ext = e;
+ emit extensionChanged();
+ }
+ }
Q_INVOKABLE int invokable() { return 123; }
+Q_SIGNALS:
+ void extensionChanged();
public slots:
int slot() { return 456; }
+private:
+ int ext = 42;
};
class Extended : public QObject
diff --git a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp
index 7e30dcad6c..263b44ae22 100644
--- a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp
+++ b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp
@@ -5634,9 +5634,20 @@ void tst_qqmllanguage::extendedForeignTypes()
QScopedPointer<QObject> o(component.create());
QVERIFY(!o.isNull());
+ QObject *extended = o->property("extended").value<QObject *>();
+ QVERIFY(extended);
+ QSignalSpy extensionChangedSpy(extended, SIGNAL(extensionChanged()));
+
QCOMPARE(o->property("extendedBase").toInt(), 43);
QCOMPARE(o->property("extendedExtension").toInt(), 42);
QCOMPARE(o->property("foreignExtendedExtension").toInt(), 42);
+
+ QCOMPARE(extensionChangedSpy.count(), 0);
+ extended->setProperty("extension", 44);
+ QCOMPARE(extensionChangedSpy.count(), 1);
+ QCOMPARE(o->property("extendedChangeCount").toInt(), 1);
+ QCOMPARE(o->property("extendedExtension").toInt(), 44);
+
QCOMPARE(o->property("foreignObjectName").toString(), QLatin1String("foreign"));
QCOMPARE(o->property("foreignExtendedObjectName").toString(), QLatin1String("foreignExtended"));
QCOMPARE(o->property("extendedInvokable").toInt(), 123);