diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2019-02-14 15:48:56 +0100 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@qt.io> | 2019-02-17 08:10:17 +0000 |
commit | 94d30df911dccd830a18d7c2e75397505ef9a600 (patch) | |
tree | e9890f9cb006fdc38bbed9fe94d553868d905166 /tests/auto/qml/qqmllanguage | |
parent | d96a700cc3611480ff76023287cb06f455a37b02 (diff) |
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 <simon.hausmann@qt.io>
Diffstat (limited to 'tests/auto/qml/qqmllanguage')
-rw-r--r-- | tests/auto/qml/qqmllanguage/data/SignalEmitter.qml | 14 |
1 files changed, 12 insertions, 2 deletions
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); |