Details
-
Bug
-
Resolution: Unresolved
-
P2: Important
-
6.4.0 Beta4
Description
toVariant() only performs "safe" conversions to the type given as hint and otherwise produces a variant of the "native" type of the JS value. Since everything can be wrapped in QVariant it never fails.
metaTypeFromJS() tries to perform any kind of conversion and returns true if anything succeeds. It can fail and return false.
There are two problems here:
- The code for the "safe" conversions is duplicated and incomplete in both locations.
- toVariant() produces a QVariant and allocates the data in the process. metaTypeFromJS() uses QMetaType (or some known copy-ctor) to copy the value to a location at a given pointer. It still requires there to be a pre-constructed value in that place (ie it does QMetaType::destruct() before constructing the new value). This needs unification.
Ideally, we account for move-constructible types and assignment operators, too. That requires changes in QMetaType. For now, untangling this mess would be quite beneficial already.