From a7ac08c19b4e19d58ac29ed727a47329e173352e Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Wed, 3 Feb 2016 14:09:43 +0100 Subject: [PATCH] KLinkItemSelectionModel: Don't store model locally The model can be changed after the constructor is run as of Qt 5.5. At this point, the KLinkItemSelectionModel would still break if that is attempted, so a unit test comes later. --- src/klinkitemselectionmodel.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/klinkitemselectionmodel.cpp b/src/klinkitemselectionmodel.cpp index 1b676e8..c187b65 100644 --- a/src/klinkitemselectionmodel.cpp +++ b/src/klinkitemselectionmodel.cpp @@ -29,13 +29,13 @@ class KLinkItemSelectionModelPrivate { public: - KLinkItemSelectionModelPrivate(KLinkItemSelectionModel *proxySelectionModel, QAbstractItemModel *model, + KLinkItemSelectionModelPrivate(KLinkItemSelectionModel *proxySelectionModel, QItemSelectionModel *linkedItemSelectionModel) : q_ptr(proxySelectionModel), - m_model(model), m_linkedItemSelectionModel(linkedItemSelectionModel), m_ignoreCurrentChanged(false), - m_indexMapper(new KModelIndexProxyMapper(model, linkedItemSelectionModel->model(), proxySelectionModel)) + m_indexMapper(new KModelIndexProxyMapper(proxySelectionModel->model(), + linkedItemSelectionModel->model(), proxySelectionModel)) { } @@ -57,7 +57,6 @@ public: void sourceCurrentChanged(const QModelIndex ¤t); void slotCurrentChanged(const QModelIndex ¤t); - QAbstractItemModel *const m_model; QItemSelectionModel *const m_linkedItemSelectionModel; bool m_ignoreCurrentChanged; KModelIndexProxyMapper *const m_indexMapper; @@ -65,7 +64,7 @@ public: KLinkItemSelectionModel::KLinkItemSelectionModel(QAbstractItemModel *model, QItemSelectionModel *proxySelector, QObject *parent) : QItemSelectionModel(model, parent), - d_ptr(new KLinkItemSelectionModelPrivate(this, model, proxySelector)) + d_ptr(new KLinkItemSelectionModelPrivate(this, proxySelector)) { connect(proxySelector, SIGNAL(selectionChanged(QItemSelection,QItemSelection)), SLOT(sourceSelectionChanged(QItemSelection,QItemSelection))); connect(proxySelector, SIGNAL(currentChanged(QModelIndex,QModelIndex)), SLOT(sourceCurrentChanged(QModelIndex)));