From 94d30df911dccd830a18d7c2e75397505ef9a600 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Thu, 14 Feb 2019 15:48:56 +0100 Subject: Check parameter types when invoking C++ functions from QML We now check if the given parameters can be converted to the expected arguments of the function being invoked and throw a type error if not. Previously we would still invoke the method with random parameters. [ChangeLog][QtQml][Important Behavior Changes] The parameters passed to C++ functions from QML are now checked for compatibility with the expected arguments. If they cannot be converted, a type error is thrown in JavaScript and the function is not invoked. Fixes: QTBUG-73405 Change-Id: If16089510d314bb7cdb7d4db86478114c61281a8 Reviewed-by: Simon Hausmann --- tests/auto/qml/qqmllanguage/data/SignalEmitter.qml | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'tests/auto/qml/qqmllanguage') diff --git a/tests/auto/qml/qqmllanguage/data/SignalEmitter.qml b/tests/auto/qml/qqmllanguage/data/SignalEmitter.qml index 259f45b7d2..31fe5e4a5e 100644 --- a/tests/auto/qml/qqmllanguage/data/SignalEmitter.qml +++ b/tests/auto/qml/qqmllanguage/data/SignalEmitter.qml @@ -10,8 +10,18 @@ QtObject { signal testSignal(SignalParam spp); function emitTestSignal() { - testObject.expectNull = true; - testSignal(op); + var caught = false; + try { + testObject.expectNull = true; + testSignal(op); + } catch(e) { + // good: We want a type error here + caught = true; + if (handleSignal) + testObject.determineSuccess(null); + } + if (!caught && handleSignal) + testObject.determineSuccess("fail"); testObject.expectNull = false; testSignal(p); -- cgit v1.2.3