@@ -1665,9 +1665,12 @@ bool ModelObject::virtualPut(Managed *m, PropertyKey id, const Value &value, Val
16651665
16661666    ExecutionEngine *eng = that->engine ();
16671667    const  int  elementIndex = that->d ()->elementIndex ();
1668-     int  roleIndex = that->d ()->m_model ->m_listModel ->setExistingProperty (elementIndex, propName, value, eng);
1669-     if  (roleIndex != -1 )
1670-         that->d ()->m_model ->emitItemsChanged (elementIndex, 1 , QVector<int >(1 , roleIndex));
1668+     if  (QQmlListModel *model = that->d ()->m_model ) {
1669+         const  int  roleIndex
1670+                 = model->listModel ()->setExistingProperty (elementIndex, propName, value, eng);
1671+         if  (roleIndex != -1 )
1672+             model->emitItemsChanged (elementIndex, 1 , QVector<int >(1 , roleIndex));
1673+     }
16711674
16721675    ModelNodeMetaObject *mo = ModelNodeMetaObject::get (that->object ());
16731676    if  (mo->initialized ())
@@ -1683,7 +1686,11 @@ ReturnedValue ModelObject::virtualGet(const Managed *m, PropertyKey id, const Va
16831686    const  ModelObject *that = static_cast <const  ModelObject*>(m);
16841687    Scope scope (that);
16851688    ScopedString name (scope, id.asStringOrSymbol ());
1686-     const  ListLayout::Role *role = that->d ()->m_model ->m_listModel ->getExistingRole (name);
1689+     QQmlListModel *model = that->d ()->m_model ;
1690+     if  (!model)
1691+         return  QObjectWrapper::virtualGet (m, id, receiver, hasProperty);
1692+ 
1693+     const  ListLayout::Role *role = model->listModel ()->getExistingRole (name);
16871694    if  (!role)
16881695        return  QObjectWrapper::virtualGet (m, id, receiver, hasProperty);
16891696    if  (hasProperty)
@@ -1696,7 +1703,7 @@ ReturnedValue ModelObject::virtualGet(const Managed *m, PropertyKey id, const Va
16961703    }
16971704
16981705    const  int  elementIndex = that->d ()->elementIndex ();
1699-     QVariant value = that-> d ()-> m_model ->data (elementIndex, role->index );
1706+     QVariant value = model ->data (elementIndex, role->index );
17001707    return  that->engine ()->fromVariant (value);
17011708}
17021709
@@ -1719,16 +1726,19 @@ PropertyKey ModelObjectOwnPropertyKeyIterator::next(const Object *o, Property *p
17191726    const  ModelObject *that = static_cast <const  ModelObject *>(o);
17201727
17211728    ExecutionEngine *v4 = that->engine ();
1722-     if  (roleNameIndex < that->listModel ()->roleCount ()) {
1729+ 
1730+     QQmlListModel *model = that->d ()->m_model ;
1731+     ListModel *listModel = model ? model->listModel () : nullptr ;
1732+     if  (listModel && roleNameIndex < listModel->roleCount ()) {
17231733        Scope scope (that->engine ());
1724-         const  ListLayout::Role &role = that-> listModel () ->getExistingRole (roleNameIndex);
1734+         const  ListLayout::Role &role = listModel->getExistingRole (roleNameIndex);
17251735        ++roleNameIndex;
17261736        ScopedString roleName (scope, v4->newString (role.name ));
17271737        if  (attrs)
17281738            *attrs = QV4::Attr_Data;
17291739        if  (pd) {
17301740
1731-             QVariant value = that-> d ()-> m_model ->data (that->d ()->elementIndex (), role.index );
1741+             QVariant value = model ->data (that->d ()->elementIndex (), role.index );
17321742            if  (auto  recursiveListModel = qvariant_cast<QQmlListModel*>(value)) {
17331743                auto  size = recursiveListModel->count ();
17341744                auto  array = ScopedArrayObject{scope, v4->newArrayObject (size)};
0 commit comments