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

ListModel with dynamicRoles enabled crashes after inserted different type of data

    XMLWordPrintable

Details

    Description

      Hi,

      I want to report a crash issue for ListModel with dynamicRoles enabled. The following code has demonstrated the problem. All the test is passed, but the program crashes on termination. It has been tested on Mac (5.2.1) and Linux (5.3.0 RC. Released on 2rd May). Both of the platform show the same problem.

      The purpose of this code is just to show different way to call the method of item in ListModel. Although it is not production code , I think Qt should not crashes by pure Javascript code.

      The program will not crash if you turn off the dynamicRoles property . The result will be all green.

      Thank you.

      import QtQuick 2.0
      import QtTest 1.0
      
      TestCase {
          name : "QML"
      
          Item {
              id : testItem
              property string name : "testObject"
              property var object : this
              function testMethod() {
                  return -1;
              }
          }
      
          ListModel {
              id : listModel
              dynamicRoles : true
          }
      
          function test_ListModel() {
              listModel.append(testItem);
              compare(listModel.count , 1);
      
              var data = listModel.get(0);
      
              compare(data !== testItem, true);
              compare(data.name , "testObject");
      
              compare(typeof data.testMethod !== "function",
                      true);
              compare(typeof data.object.testMethod , "function");
      
              compare(data.object.testMethod() , -1);
      
              listModel.clear();
              listModel.append({ item : testItem });
              data = listModel.get(0);
      
              compare(data.item === testItem, true);
              compare(data.item.name , "testObject");
      
              compare(typeof data.item.testMethod , "function");
          }
      }
      

      The backtrack

      0	QMetaObject::cast(QObject*) const	QMetaObject::cast(QObject*) const		0x100bc2b6e	
      1	QtPrivate::QVariantValueHelper<QObject*>::object(QVariant const&)	QtPrivate::QVariantValueHelper<QObject*>::object(QVariant const&)		0x10040d4ae	
      2	DynamicRoleModelNodeMetaObject::~DynamicRoleModelNodeMetaObject()	DynamicRoleModelNodeMetaObject::~DynamicRoleModelNodeMetaObject()		0x10066e8b5	
      3	DynamicRoleModelNodeMetaObject::~DynamicRoleModelNodeMetaObject()	DynamicRoleModelNodeMetaObject::~DynamicRoleModelNodeMetaObject()		0x10066e83e	
      4	QObjectPrivate::~QObjectPrivate()	QObjectPrivate::~QObjectPrivate()		0x100be4a8d	
      5	QObjectPrivate::~QObjectPrivate()	QObjectPrivate::~QObjectPrivate()		0x100be49af	
      6	QObject::~QObject()	QObject::~QObject()		0x100be6574	
      7	DynamicRoleModelNode::~DynamicRoleModelNode()	DynamicRoleModelNode::~DynamicRoleModelNode()		0x10067516e	
      8	QQmlListModel::~QQmlListModel()	QQmlListModel::~QQmlListModel()		0x10066f294	
      9	QQmlPrivate::QQmlElement<QQmlListModel>::~QQmlElement()	QQmlPrivate::QQmlElement<QQmlListModel>::~QQmlElement()		0x100560814	
      10	QObjectPrivate::deleteChildren()	QObjectPrivate::deleteChildren()		0x100be674e	
      11	QObject::~QObject()	QObject::~QObject()		0x100be6554	
      12	QQmlPrivate::QQmlElement<QQuickItem>::~QQmlElement()	QQmlPrivate::QQmlElement<QQuickItem>::~QQmlElement()		0x1000f0aeb	
      13	QQuickView::~QQuickView()	QQuickView::~QQuickView()		0x100167cfe	
      14	QQuickView::~QQuickView()	QQuickView::~QQuickView()		0x100167c5e	
      15	quick_test_main(int, char**, char const*, char const*)	quick_test_main(int, char**, char const*, char const*)		0x1014271f7	
      16	main	main.cpp	12	0x10000433d	
      

      Completed program has been attached.

      Attachments

        Issue Links

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

          Activity

            People

              shausman Simon Hausmann
              benlau Ben Lau
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes