diff options
author | Sami Shalayel <sami.shalayel@qt.io> | 2022-10-12 15:56:00 +0200 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@qt.io> | 2022-12-07 13:50:01 +0100 |
commit | ee9e3a10d967874eddc5400b2b7aa36950140b9b (patch) | |
tree | 0765f56ac0ea367140b241235eb571b295d152d1 /src/qml/doc/snippets | |
parent | a354d91b885b16e6246d7ff166244b31d33f56a7 (diff) |
qmltc: fix handlers for c++-signals
Allow qmltc to generate handlers for c++-defined signals with const
parameters by changing the safeguard to avoid type mismatch between
slots and signals.
First, remove the qOverload in the generated QObject::connect call to
be able the connect slots and signals with different types (namely,
pass by const references and pass by value should be interchangeable but
is not allowed by qOverload).
Second, save in QQmlJSMetaParameter when types are passed by pointer.
Like this, qqmljsimportvisitor can check if a value type is indeed
passed by value or const reference in a C++ signal. The same for reference
types that need to be passed by (const and non-const) pointer.
Print a message when an type is passed by argument in an incompatible
way instead of letting qmltc generate uncompilable code, which makes the
compiler print out cryptical messages.
Third, add a qqmlcpptypehelpers template that decides if value types
should be passed by value or reference, by letting the c++ compiler
check if sizeof(T) > 3*sizeof(void*).
Fixes: QTBUG-107625
Fixes: QTBUG-107622
Change-Id: I1a00532df591d10f74c1fd00dff5b7fccf40cb22
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'src/qml/doc/snippets')
-rw-r--r-- | src/qml/doc/snippets/qmltc/special/HelloWorld.qml.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/qml/doc/snippets/qmltc/special/HelloWorld.qml.cpp b/src/qml/doc/snippets/qmltc/special/HelloWorld.qml.cpp index 732d915b99..eda9009bb7 100644 --- a/src/qml/doc/snippets/qmltc/special/HelloWorld.qml.cpp +++ b/src/qml/doc/snippets/qmltc/special/HelloWorld.qml.cpp @@ -31,7 +31,7 @@ public: void setHello(const QString& hello_); QString hello(); QBindable<QString> bindableHello(); - Q_INVOKABLE void printHello(QString prefix, QString suffix); + Q_INVOKABLE void printHello(passByConstRefOrValue<QString> prefix, passByConstRefOrValue<QString> suffix); // ... }; |