Handle type mismatches between source and replica
If the source and the replica disagree on a type, a value can arrive
whose type differs from the one the receiver expects. This applies to
slot arguments, property values and signal arguments. Previously such
values were passed on to the receiver as-is, which caused undefined
behavior and crashes.
Update decodeVariant() to convert the received value to the expected
type if possible, or use a default-constructed value of the expected
type. This is in line with the pre-existing way of handling
unsupported containers in QSQ_ and QAS_ cases. The updated method is
now also used to decode values written to properties.
The provided tests use a repc-generated replica and a QObject-based
source with mismatching types in slot arguments and properties.
They handle both the case when the passed type converts to the
expected type, and when it does not. The tests were crashing without
the fixes.
Fixes: QTBUG-150757
Pick-to: 6.12 6.8 6.5 5.15
Change-Id: I2bca44bc6ff0b685055bd52b422bd2c886a076a5
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>