From ed8e89eaddca1c508151ef5913f0d383d3071b99 Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Wed, 9 Sep 2009 14:43:26 +1000 Subject: Fix destruction of ModelNodes (fix crash-on-exit). --- src/declarative/util/qmllistmodel.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/declarative/util/qmllistmodel.cpp b/src/declarative/util/qmllistmodel.cpp index 82942f6..8e5ea9c 100644 --- a/src/declarative/util/qmllistmodel.cpp +++ b/src/declarative/util/qmllistmodel.cpp @@ -200,7 +200,7 @@ class ModelObject : public QObject { Q_OBJECT public: - ModelObject(ModelNode *); + ModelObject(); void setValue(const QByteArray &name, const QVariant &val) { @@ -208,8 +208,6 @@ public: } private: - ModelNode *_node; - bool _haveProperties; QmlOpenMetaObject *_mo; }; @@ -231,7 +229,7 @@ struct ModelNode ModelObject *object() { if (!objectCache) { - objectCache = new ModelObject(this); + objectCache = new ModelObject(); QHash::iterator it; for (it = properties.begin(); it != properties.end(); ++it) { if (!(*it)->values.isEmpty()) @@ -294,8 +292,8 @@ struct ModelNode ModelObject *objectCache; }; -ModelObject::ModelObject(ModelNode *node) -: _node(node), _haveProperties(false), _mo(new QmlOpenMetaObject(this)) +ModelObject::ModelObject() +: _mo(new QmlOpenMetaObject(this)) { } @@ -841,7 +839,8 @@ ModelNode::~ModelNode() ModelNode *node = qvariant_cast(values.at(ii)); if (node) { delete node; node = 0; } } - if (modelCache) { delete modelCache; modelCache = 0; } + if (modelCache) { modelCache->_root = 0/* ==this */; delete modelCache; modelCache = 0; } + if (objectCache) { delete objectCache; } } QT_END_NAMESPACE -- cgit v0.12