diff options
author | Gabriel de Dietrich <gabriel.dedietrich@theqtcompany.com> | 2015-05-21 10:56:25 +0200 |
---|---|---|
committer | Gabriel de Dietrich <gabriel.dedietrich@theqtcompany.com> | 2015-05-21 12:47:52 +0000 |
commit | c317ed601212aa657fe06ebc9f773e0e8941b511 (patch) | |
tree | ec9dd02ae300a89cbdeb0deb0d9116e7867953c7 /src/controls/Private/qquicktreemodeladaptor_p.h | |
parent | 68cb8236ca7d02fe726e233618eaddc978f33e1f (diff) | |
download | qtquickcontrols-c317ed601212aa657fe06ebc9f773e0e8941b511.tar.gz |
TreeModelAdaptor: Monitor model's lifespan
We make the model adaptor behave as if it had no model
set if the model gets deleted. Also, while not strictly
necessary, using a QPointer adds some extra safety.
Change-Id: Ic6963319678acee0097dcddfea36059f9046b093
Task-number: QTBUG-46214
Reviewed-by: J-P Nurmi <jpnurmi@theqtcompany.com>
Reviewed-by: Caroline Chao <caroline.chao@theqtcompany.com>
Diffstat (limited to 'src/controls/Private/qquicktreemodeladaptor_p.h')
-rw-r--r-- | src/controls/Private/qquicktreemodeladaptor_p.h | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/controls/Private/qquicktreemodeladaptor_p.h b/src/controls/Private/qquicktreemodeladaptor_p.h index 98b1e49e..8059f681 100644 --- a/src/controls/Private/qquicktreemodeladaptor_p.h +++ b/src/controls/Private/qquicktreemodeladaptor_p.h @@ -49,6 +49,7 @@ // #include <QtCore/qset.h> +#include <QtCore/qpointer.h> #include <QtCore/qabstractitemmodel.h> #include <QtCore/qitemselectionmodel.h> @@ -119,6 +120,7 @@ public slots: void setModel(QAbstractItemModel *model); private slots: + void modelHasBeenDestroyed(); void modelHasBeenReset(); void modelDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRigth, const QVector<int> &roles); void modelLayoutAboutToBeChanged(const QList<QPersistentModelIndex> &parents, QAbstractItemModel::LayoutChangeHint hint); @@ -146,7 +148,7 @@ private: } }; - QAbstractItemModel *m_model; + QPointer<QAbstractItemModel> m_model; QList<TreeItem> m_items; QSet<QPersistentModelIndex> m_expandedItems; QList<TreeItem *> m_itemsToExpand; |