diff options
author | Kai Uwe Broulik <kde@privat.broulik.de> | 2023-08-17 23:09:21 +0200 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@qt.io> | 2023-08-22 09:12:56 +0200 |
commit | 139d45c062ce6061b96f7ffe206babde4b596a98 (patch) | |
tree | baa682f5741d8284731798f5c20e217b5c0f156d /tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp | |
parent | 5789ae5da56b4f17fd126154f8a55bc7fcd936d8 (diff) |
QV4::QObjectWrapper: Use the object's actual meta type
Otherwise, a derived type's methods will not be found.
In our particular case we tried to call a method of 'B*' on a
QML attached property declared as 'A*'.
This restores the previous behavior of using the object()
for the meta type except for when it's a value type wrapper.
Amends commit 63b622d5908ec2960ce5dfa301e9d3fd4d92fdb4.
Pick-to: 6.6 6.5 6.2
Change-Id: I08b9f4b97a58c15fdc3703dd3c5d927cd1beb3ce
Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Semih Yavuz <semih.yavuz@qt.io>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp')
-rw-r--r-- | tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp index a7458af7ed..339f881e71 100644 --- a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp +++ b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp @@ -431,6 +431,8 @@ private slots: void signalNames_data(); void signalNames(); + void callMethodOfAttachedDerived(); + private: QQmlEngine engine; QStringList defaultImportPathList; @@ -8253,6 +8255,27 @@ Item { QVERIFY(changeSignal.size() == 2); } +void tst_qqmllanguage::callMethodOfAttachedDerived() +{ + QQmlEngine engine; + QQmlComponent c(&engine); + c.setData(R"( + import QtQml + import Test + + QtObject { + Component.onCompleted: Counter.increase() + property int v: Counter.value + } + )", QUrl()); + + QVERIFY2(c.isReady(), qPrintable(c.errorString())); + QScopedPointer<QObject> o(c.create()); + QVERIFY(!o.isNull()); + + QCOMPARE(o->property("v").toInt(), 99); +} + QTEST_MAIN(tst_qqmllanguage) #include "tst_qqmllanguage.moc" |