diff options
author | Maximilian Goldstein <max.goldstein@qt.io> | 2021-02-09 11:37:45 +0100 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2021-02-10 16:12:09 +0000 |
commit | b2fccf2f2d15c91cf52ca9a2a779eae3004f8b55 (patch) | |
tree | 640f75fa78ae04bb2190541d5b127ab52c34a19a /tests/auto/qml | |
parent | 16a09446677b196bd763b54dc5e2b46afaf5add5 (diff) |
Fix QJSValue string parameters used in signals
Fixes: QTBUG-86482
Change-Id: If938fad22f51b08fe3cb20b94634efe46a1eed47
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
(cherry picked from commit e887f25dd6c4c9630a7367c3a2ed95a284191843)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'tests/auto/qml')
-rw-r--r-- | tests/auto/qml/qqmllanguage/testtypes.h | 11 | ||||
-rw-r--r-- | tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp | 21 |
2 files changed, 32 insertions, 0 deletions
diff --git a/tests/auto/qml/qqmllanguage/testtypes.h b/tests/auto/qml/qqmllanguage/testtypes.h index 77f09a232c..8f4071d9b8 100644 --- a/tests/auto/qml/qqmllanguage/testtypes.h +++ b/tests/auto/qml/qqmllanguage/testtypes.h @@ -1700,6 +1700,17 @@ public: int g() const { return 44; } }; +class StringSignaler : public QObject +{ + Q_OBJECT + QML_ELEMENT +public: + StringSignaler(QObject *parent = nullptr) : QObject(parent) {} + Q_INVOKABLE void call() { emit signal(QJSValue("Hello world!")); } +signals: + void signal(QJSValue value); +}; + void registerTypes(); #endif // TESTTYPES_H diff --git a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp index eaee7883f7..46fb83ac9f 100644 --- a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp +++ b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp @@ -346,6 +346,7 @@ private slots: void factorySingleton(); void extendedSingleton(); void qtbug_85932(); + void qtbug_86482(); void multiExtension(); void invalidInlineComponent(); @@ -6166,6 +6167,26 @@ void tst_qqmllanguage::invalidInlineComponent() QVERIFY(c.errorString().contains("\"Window.visibility\" is not available in QtQuick 2.0.")); } +void tst_qqmllanguage::qtbug_86482() +{ + QQmlEngine engine; + QQmlComponent component(&engine); + component.setData(QByteArray(R"(import QtQml 2.0 + import StaticTest + QtObject { + id: root + property string result + property StringSignaler str: StringSignaler { + onSignal: function(value) { root.result = value; } + } + Component.onCompleted: str.call(); + })"), QUrl()); + VERIFY_ERRORS(0); + QScopedPointer<QObject> o(component.create()); + QVERIFY2(component.isReady(), qPrintable(component.errorString())); + QCOMPARE(o->property("result").toString(), QStringLiteral("Hello world!")); +} + QTEST_MAIN(tst_qqmllanguage) #include "tst_qqmllanguage.moc" |