Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-42016

QSequentialIterable crashes with custom QVariantList converter for QML arrays

    XMLWordPrintable

Details

    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

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              thiago Thiago Macieira
              milianw Milian Wolff
              Votes:
              0 Vote for this issue
              Watchers:
              11 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes