Details
-
Bug
-
Resolution: Fixed
-
P2: Important
-
5.4.0 Alpha, 5.9.6
-
None
Description
The attached test case shows an assertion (debug mode) or crash (release mode). It happens when one tries to use QSequentialIterable on a QJSValue that represents a QML array, wrapped in a QVariant. In such a case, apparently a default-constructed QSequentialIterableImpl (all data members are zero) gets associated with the QSequentialIterable. Calling .size() on it asserts. Trying to iterate over it will crash because the _moveToBegin function pointers are nullptrs.
I could not reproduce the bug by creating a QJSValue via QQmlEngine::newArray.
I assume this crash will manifest whenever one adds a custom QVariantList converter to any datatype. The documentation says that this is enough to make QSequentialIterable work, but this code shows it is not the case.
I think the bug must be solved somehow in qmetatype.h by adding more magic to the QSequentialIterable, maybe by using a fallback that does actually convert to a QVariantList.
For performance reasons, the QJSValue should probably also get a QSequentialIterableImpl converter which then allows one to iterate over the contents without constructing a temporary QVariantList.
Attachments
Issue Links
- relates to
-
QTBUG-73437 QJsonObject to QAssociativeIterable conversion fails
- Open