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

Crash when calling Object.value() on QQmlListModel

    XMLWordPrintable

Details

    • e37daba8c (dev), b050778c4 (6.9), daa24ca0c (tqtc/lts-6.8), 04696fe0f (tqtc/lts-6.5)

    Description

      Code

      import QtQuick
      
      Window {
          width: 640
          height: 480
          visible: true
      
          ListModel { id: listModel }
      
          Component.onCompleted: {
              const rawObj = { innerList: [1, 2, 3] }
              listModel.append(rawObj)
              const convertedObj = listModel.get(0)
      
              console.log(rawObj.innerList)
              console.log(Object.values(rawObj.innerList)) // <-- OK
      
              console.log(convertedObj.innerList)
              console.log(Object.values(convertedObj.innerList)) // <-- Crashes
          }
      }
      

       

      Notes
      If we replace the JS array with a C++ QStringList...

      const rawObj = { innerList: CppSingleton.qStringListProp }
      

      ...then it won't crash in Qt 6.5 because convertedObj.innerList is a JS object (as opposed to a QQmlListModel in Qt 6.8+)

      Attachments

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

        Activity

          People

            ulherman Ulf Hermann
            skoh-qt Sze Howe Koh
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: