Details
-
Bug
-
Resolution: Duplicate
-
Not Evaluated
-
None
-
5.1.1
-
None
-
Linux, Windows
Description
QObject::setProperty normally checks that the passed-in type can be converted to the target type and doesn't call the setter function if it cannot. This works with user-defined variant types as well: if you pass a wrong type, the setter function won't be called at all.
However, when the custom type is registered with qRegisterMetatype, the check no longer works. If you pass an object of a wrong type to setProperty, the setter function will be called with an object that is filled with zeros. This is fatal for example with classes that contain a d pointer.
The attached project illustrates this. Commenting out qRegisterMetaType() solves the problem.
Attachments
Issue Links
- is replaced by
-
QTBUG-40644 Crash: Setting qobject property with QVariant() will cause crash
-
- Open
-
- relates to
-
QTBUG-40644 Crash: Setting qobject property with QVariant() will cause crash
-
- Open
-