Reject object references of the wrong class


toVariant() resolved a JSON object reference without checking that the
object is of the parameter's or property's class. A client could name
any object the channel has exposed to it and have a slot use it as an
unrelated type.

Reject the argument unless the resolved object inherits the target
metatype's metaobject, and reject when no metaobject is available to
check against. Apply the same check in conversionScore(), so overload
resolution does not select a candidate the argument cannot satisfy.

Pick-to: 6.8 6.12
Task-number: QTBUG-151083
Change-Id: I001e51bba581bf9496beb48c9b37d79caf5a35af
Reviewed-by: Arno Rehn <a.rehn@menlosystems.com>
commitbf9ace6e263874bf8d2a668eccd2554a0cf84e50
parent37cd0af8110396eb5cf85b864b7c6fc4cb486c37
authorMagdalena Stojek <magdalena.stojek@qt.io>
committerMagdalena Stojek <magdalena.stojek@qt.io>
commit timeTue, 13 Oct 2026 06:55:10 +0000