aboutsummaryrefslogtreecommitdiffstats
path: root/src/qmlmodels/qqmllistmodel_p_p.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/qmlmodels/qqmllistmodel_p_p.h')
-rw-r--r--src/qmlmodels/qqmllistmodel_p_p.h24
1 files changed, 16 insertions, 8 deletions
diff --git a/src/qmlmodels/qqmllistmodel_p_p.h b/src/qmlmodels/qqmllistmodel_p_p.h
index 19cba980f4..da04b0a5f5 100644
--- a/src/qmlmodels/qqmllistmodel_p_p.h
+++ b/src/qmlmodels/qqmllistmodel_p_p.h
@@ -161,13 +161,23 @@ struct ModelObject : public QObjectWrapper {
{
QObjectWrapper::init(object);
m_model = model;
- QObjectPrivate *op = QObjectPrivate::get(object);
- m_nodeModelMetaObject = static_cast<ModelNodeMetaObject *>(op->metaObject);
}
- void destroy() { QObjectWrapper::destroy(); }
- int elementIndex() const { return m_nodeModelMetaObject->m_elementIndex; }
- QQmlListModel *m_model;
- ModelNodeMetaObject *m_nodeModelMetaObject;
+
+ void destroy()
+ {
+ m_model.destroy();
+ QObjectWrapper::destroy();
+ }
+
+ int elementIndex() const {
+ if (const QObject *o = object()) {
+ const QObjectPrivate *op = QObjectPrivate::get(o);
+ return static_cast<ModelNodeMetaObject *>(op->metaObject)->m_elementIndex;
+ }
+ return -1;
+ }
+
+ QV4QPointer<QQmlListModel> m_model;
};
}
@@ -177,8 +187,6 @@ struct ModelObject : public QObjectWrapper
V4_OBJECT2(ModelObject, QObjectWrapper)
V4_NEEDS_DESTROY
- ListModel *listModel() const { return d()->m_model->m_listModel; }
-
protected:
static bool virtualPut(Managed *m, PropertyKey id, const Value& value, Value *receiver);
static ReturnedValue virtualGet(const Managed *m, PropertyKey id, const Value *receiver, bool *hasProperty);