From a056cb9595ea4a41c93f4c912719f9523b943d3b Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Fri, 3 Jul 2020 08:23:32 +0200 Subject: Give a better score for methods with a convertable type when matching When it is looking for a matching method based on the argument types, then if a QVariant can be converted to that type then it should give a better score for that method. This is so that it can see it as being more viable a choice when calling the method instead of potentially not being able to find a matching one. Pick-to: 5.15 Change-Id: Ief7e11feacd1d0b0959330af2576c2d01affbc54 Reviewed-by: Ulf Hermann --- tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp | 14 ++++++++++++++ 1 file changed, 14 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 98dc106ebe..52b2afe727 100644 --- a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp +++ b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp @@ -388,6 +388,7 @@ private slots: void urlPropertySet(); void urlSearchParamsConstruction(); void urlSearchParamsMethods(); + void variantConversionMethod(); void gcCrashRegressionTest(); @@ -9533,6 +9534,19 @@ void tst_qqmlecmascript::urlSearchParamsMethods() QVERIFY(EVALUATE_VALUE("this.usp.toString()", QV4::ScopedValue(scope, scope.engine->newString("a=10&c=foo")))); } +void tst_qqmlecmascript::variantConversionMethod() +{ + QQmlEngine qmlengine; + + VariantConvertObject obj; + qmlengine.rootContext()->setContextProperty("variantObject", &obj); + + QQmlComponent component(&qmlengine, testFileUrl("variantConvert.qml")); + QScopedPointer o(component.create()); + QVERIFY(o != nullptr); + QCOMPARE(obj.funcCalled, QLatin1String("QModelIndex")); +} + QTEST_MAIN(tst_qqmlecmascript) #include "tst_qqmlecmascript.moc" -- cgit v1.2.3