From fe8e388418608b4d07b3d8325915af05d386b993 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Tue, 6 Jun 2023 08:39:59 +0200 Subject: QML: Fix overload resolution for QObject* types Amazingly, QObject pointers were not supported at all so far. Pick-to: 6.5 6.6 Change-Id: I61b28705d3bebf9602bdeee05aadcb085f39b184 Reviewed-by: Qt CI Bot Reviewed-by: Fabian Kosmale --- .../auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp | 32 ++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp') diff --git a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp index 2684157840..ab880957ac 100644 --- a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp +++ b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp @@ -3191,6 +3191,17 @@ void tst_qqmlecmascript::callQtInvokables() QCOMPARE(o->invoked(), -1); // no function got called due to incompatible arguments } + { + o->reset(); + QQmlComponent comp(&qmlengine, testFileUrl("qmlTypeWrapperArgs3.qml")); + QScopedPointer root {comp.createWithInitialProperties({{"invokableObject", QVariant::fromValue(o)}}) }; + QVERIFY(root); + QCOMPARE(o->error(), false); + QCOMPARE(o->actuals().size(), 2); + QCOMPARE(o->actuals().at(0).metaType(), QMetaType::fromType()); + QCOMPARE(o->actuals().at(1).metaType(), QMetaType::fromType()); + } + o->reset(); QVERIFY(EVALUATE_VALUE("object.method_QObject(undefined)", QV4::Primitive::undefinedValue())); QCOMPARE(o->error(), false); @@ -3522,6 +3533,27 @@ void tst_qqmlecmascript::callQtInvokables() QCOMPARE(o->error(), false); QCOMPARE(o->invoked(), -1); QCOMPARE(o->actuals(), QVariantList()); + + o->reset(); + QVERIFY(EVALUATE_VALUE("object.method_component(object.someComponent())", + QV4::Primitive::undefinedValue())); + QCOMPARE(o->error(), false); + QCOMPARE(o->invoked(), 42); + QCOMPARE(o->actuals(), QVariantList() << QVariant::fromValue(o->someComponent())); + + o->reset(); + QVERIFY(EVALUATE_VALUE("object.method_component(object.someTypeObject())", + QV4::Primitive::undefinedValue())); + QCOMPARE(o->error(), false); + QCOMPARE(o->invoked(), 43); + QCOMPARE(o->actuals(), QVariantList() << QVariant::fromValue(o->someTypeObject())); + + o->reset(); + QVERIFY(EVALUATE_VALUE("object.method_component('qrc:/somewhere/else')", + QV4::Primitive::undefinedValue())); + QCOMPARE(o->error(), false); + QCOMPARE(o->invoked(), 44); + QCOMPARE(o->actuals(), QVariantList() << QVariant::fromValue(QUrl("qrc:/somewhere/else"))); } void tst_qqmlecmascript::resolveClashingProperties() -- cgit v1.2.3