diff options
Diffstat (limited to 'src/declarative/util/qmlpackage.cpp')
-rw-r--r-- | src/declarative/util/qmlpackage.cpp | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/src/declarative/util/qmlpackage.cpp b/src/declarative/util/qmlpackage.cpp index f9238ca..3214dc8 100644 --- a/src/declarative/util/qmlpackage.cpp +++ b/src/declarative/util/qmlpackage.cpp @@ -42,6 +42,7 @@ #include "qmlpackage_p.h" #include <private/qobject_p.h> +#include "private/qmlguard_p.h" QT_BEGIN_NAMESPACE @@ -50,7 +51,28 @@ class QmlPackagePrivate : public QObjectPrivate public: QmlPackagePrivate() {} - QmlConcreteList<QObject *> dataList; + class DataList; + struct DataGuard : public QmlGuard<QObject> + { + DataGuard(QObject *obj, DataList *l) : list(l) { (QmlGuard<QObject>&)*this = obj; } + DataList *list; + void objectDestroyed(QObject *) { + // we assume priv will always be destroyed after objectDestroyed calls + list->removeOne(*this); + } + }; + + class DataList : public QList<DataGuard>, public QmlList<QObject*> + { + public: + virtual void append(QObject* v) { QList<DataGuard>::append(DataGuard(v, this)); } + virtual void insert(int i, QObject* v) { QList<DataGuard>::insert(i, DataGuard(v, this)); } + virtual void clear() { QList<DataGuard>::clear(); } + virtual QObject* at(int i) const { return QList<DataGuard>::at(i); } + virtual void removeAt(int i) { QList<DataGuard>::removeAt(i); } + virtual int count() const { return QList<DataGuard>::count(); } + }; + DataList dataList; }; class QmlPackageAttached : public QObject |