diff options
author | Lars Knoll <lars.knoll@digia.com> | 2013-05-24 14:50:03 +0200 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@digia.com> | 2013-05-24 16:16:39 +0200 |
commit | 876f6d028d3c3934ca644cd369b2329dd613efb5 (patch) | |
tree | bd3894f63d62f7247771039aa3b2fca629794003 /src/qml/types/qqmllistmodelworkeragent_p.h | |
parent | 273ac56261707654a891d7bf7d01df3d0053f5af (diff) |
Fixup list model serialization
We need to properly refcount the agent, so it doesn't get
deleted when it's still in use.
Change-Id: Id9a0764e15c10e7b15a216523d6b22764ac863dc
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'src/qml/types/qqmllistmodelworkeragent_p.h')
-rw-r--r-- | src/qml/types/qqmllistmodelworkeragent_p.h | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/qml/types/qqmllistmodelworkeragent_p.h b/src/qml/types/qqmllistmodelworkeragent_p.h index 80ed5d9a61..e39c6f860f 100644 --- a/src/qml/types/qqmllistmodelworkeragent_p.h +++ b/src/qml/types/qqmllistmodelworkeragent_p.h @@ -90,6 +90,22 @@ public: Q_INVOKABLE void move(int from, int to, int count); Q_INVOKABLE void sync(); + struct VariantRef + { + VariantRef() : a(0) {} + VariantRef(const VariantRef &r) : a(r.a) { if (a) a->addref(); } + VariantRef(QQmlListModelWorkerAgent *_a) : a(_a) { if (a) a->addref(); } + ~VariantRef() { if (a) a->release(); } + + VariantRef &operator=(const VariantRef &o) { + if (o.a) o.a->addref(); + if (a) a->release(); a = o.a; + return *this; + } + + QQmlListModelWorkerAgent *a; + }; + void modelDestroyed(); protected: virtual bool event(QEvent *); @@ -135,5 +151,7 @@ private: QT_END_NAMESPACE +Q_DECLARE_METATYPE(QQmlListModelWorkerAgent::VariantRef) + #endif // QQUICKLISTMODELWORKERAGENT_P_H |