diff options
author | k.blammo@gmail.com <k.blammo@gmail.com> | 2012-03-09 11:29:09 (GMT) |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-04-10 19:39:21 (GMT) |
commit | 84f1adde4fb6cadf57099bd8e6130ceee8ba533b (patch) | |
tree | 4c6c015c608a5cc666732a5e1a61093d0ad41796 /src/gui | |
parent | 2def68e11b634b29f220cab6ecc78aa23d5f591c (diff) | |
download | Qt-84f1adde4fb6cadf57099bd8e6130ceee8ba533b.zip Qt-84f1adde4fb6cadf57099bd8e6130ceee8ba533b.tar.gz Qt-84f1adde4fb6cadf57099bd8e6130ceee8ba533b.tar.bz2 |
Disconnect slots from the old sourcemodel in QIdentityProxyModel
When setting a new sourcemodel QIdentityProxyModel::setSourceModel
tries to disconnect from signals belonging to the NEW model instead of
from the existing sourceModel(). QIdentityProxyModel thus receives
signals from both the old model(s) and the new model. This results in
ASSERTS triggering in various slots, for example:
"Q_ASSERT(topLeft.isValid() ? topLeft.model() == model : true);"
in QIdentityProxyModelPrivate::_q_sourceDataChanged.
Change-Id: Ic6f65a9ee10981d00206335f2edef78272fadc1a
Reviewed-by: Stephen Kelly <stephen.kelly@kdab.com>
(cherry picked from commit fae4a2555a9402e8cecf67242b29dca624cc61e8)
Reviewed-by: Girish Ramakrishnan <girish.1.ramakrishnan@nokia.com>
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/itemviews/qidentityproxymodel.cpp | 80 |
1 files changed, 40 insertions, 40 deletions
diff --git a/src/gui/itemviews/qidentityproxymodel.cpp b/src/gui/itemviews/qidentityproxymodel.cpp index ee36b831..4e1d16b 100644 --- a/src/gui/itemviews/qidentityproxymodel.cpp +++ b/src/gui/itemviews/qidentityproxymodel.cpp @@ -322,87 +322,87 @@ int QIdentityProxyModel::rowCount(const QModelIndex& parent) const /*! \reimp */ -void QIdentityProxyModel::setSourceModel(QAbstractItemModel* sourceModel) +void QIdentityProxyModel::setSourceModel(QAbstractItemModel* newSourceModel) { beginResetModel(); - if (sourceModel) { - disconnect(sourceModel, SIGNAL(rowsAboutToBeInserted(const QModelIndex &, int, int)), + if (sourceModel()) { + disconnect(sourceModel(), SIGNAL(rowsAboutToBeInserted(const QModelIndex &, int, int)), this, SLOT(_q_sourceRowsAboutToBeInserted(const QModelIndex &, int, int))); - disconnect(sourceModel, SIGNAL(rowsInserted(const QModelIndex &, int, int)), + disconnect(sourceModel(), SIGNAL(rowsInserted(const QModelIndex &, int, int)), this, SLOT(_q_sourceRowsInserted(const QModelIndex &, int, int))); - disconnect(sourceModel, SIGNAL(rowsAboutToBeRemoved(const QModelIndex &, int, int)), + disconnect(sourceModel(), SIGNAL(rowsAboutToBeRemoved(const QModelIndex &, int, int)), this, SLOT(_q_sourceRowsAboutToBeRemoved(const QModelIndex &, int, int))); - disconnect(sourceModel, SIGNAL(rowsRemoved(const QModelIndex &, int, int)), + disconnect(sourceModel(), SIGNAL(rowsRemoved(const QModelIndex &, int, int)), this, SLOT(_q_sourceRowsRemoved(const QModelIndex &, int, int))); - disconnect(sourceModel, SIGNAL(rowsAboutToBeMoved(const QModelIndex &, int, int, const QModelIndex &, int)), + disconnect(sourceModel(), SIGNAL(rowsAboutToBeMoved(const QModelIndex &, int, int, const QModelIndex &, int)), this, SLOT(_q_sourceRowsAboutToBeMoved(const QModelIndex &, int, int, const QModelIndex &, int))); - disconnect(sourceModel, SIGNAL(rowsMoved(const QModelIndex &, int, int, const QModelIndex &, int)), + disconnect(sourceModel(), SIGNAL(rowsMoved(const QModelIndex &, int, int, const QModelIndex &, int)), this, SLOT(_q_sourceRowsMoved(const QModelIndex &, int, int, const QModelIndex &, int))); - disconnect(sourceModel, SIGNAL(columnsAboutToBeInserted(const QModelIndex &, int, int)), + disconnect(sourceModel(), SIGNAL(columnsAboutToBeInserted(const QModelIndex &, int, int)), this, SLOT(_q_sourceColumnsAboutToBeInserted(const QModelIndex &, int, int))); - disconnect(sourceModel, SIGNAL(columnsInserted(const QModelIndex &, int, int)), + disconnect(sourceModel(), SIGNAL(columnsInserted(const QModelIndex &, int, int)), this, SLOT(_q_sourceColumnsInserted(const QModelIndex &, int, int))); - disconnect(sourceModel, SIGNAL(columnsAboutToBeRemoved(const QModelIndex &, int, int)), + disconnect(sourceModel(), SIGNAL(columnsAboutToBeRemoved(const QModelIndex &, int, int)), this, SLOT(_q_sourceColumnsAboutToBeRemoved(const QModelIndex &, int, int))); - disconnect(sourceModel, SIGNAL(columnsRemoved(const QModelIndex &, int, int)), + disconnect(sourceModel(), SIGNAL(columnsRemoved(const QModelIndex &, int, int)), this, SLOT(_q_sourceColumnsRemoved(const QModelIndex &, int, int))); - disconnect(sourceModel, SIGNAL(columnsAboutToBeMoved(const QModelIndex &, int, int, const QModelIndex &, int)), + disconnect(sourceModel(), SIGNAL(columnsAboutToBeMoved(const QModelIndex &, int, int, const QModelIndex &, int)), this, SLOT(_q_sourceColumnsAboutToBeMoved(const QModelIndex &, int, int, const QModelIndex &, int))); - disconnect(sourceModel, SIGNAL(columnsMoved(const QModelIndex &, int, int, const QModelIndex &, int)), + disconnect(sourceModel(), SIGNAL(columnsMoved(const QModelIndex &, int, int, const QModelIndex &, int)), this, SLOT(_q_sourceColumnsMoved(const QModelIndex &, int, int, const QModelIndex &, int))); - disconnect(sourceModel, SIGNAL(modelAboutToBeReset()), + disconnect(sourceModel(), SIGNAL(modelAboutToBeReset()), this, SLOT(_q_sourceModelAboutToBeReset())); - disconnect(sourceModel, SIGNAL(modelReset()), + disconnect(sourceModel(), SIGNAL(modelReset()), this, SLOT(_q_sourceModelReset())); - disconnect(sourceModel, SIGNAL(dataChanged(const QModelIndex &, const QModelIndex &)), + disconnect(sourceModel(), SIGNAL(dataChanged(const QModelIndex &, const QModelIndex &)), this, SLOT(_q_sourceDataChanged(const QModelIndex &, const QModelIndex &))); - disconnect(sourceModel, SIGNAL(headerDataChanged(Qt::Orientation,int,int)), + disconnect(sourceModel(), SIGNAL(headerDataChanged(Qt::Orientation,int,int)), this, SLOT(_q_sourceHeaderDataChanged(Qt::Orientation,int,int))); - disconnect(sourceModel, SIGNAL(layoutAboutToBeChanged()), + disconnect(sourceModel(), SIGNAL(layoutAboutToBeChanged()), this, SLOT(_q_sourceLayoutAboutToBeChanged())); - disconnect(sourceModel, SIGNAL(layoutChanged()), + disconnect(sourceModel(), SIGNAL(layoutChanged()), this, SLOT(_q_sourceLayoutChanged())); } - QAbstractProxyModel::setSourceModel(sourceModel); + QAbstractProxyModel::setSourceModel(newSourceModel); - if (sourceModel) { - connect(sourceModel, SIGNAL(rowsAboutToBeInserted(const QModelIndex &, int, int)), + if (sourceModel()) { + connect(sourceModel(), SIGNAL(rowsAboutToBeInserted(const QModelIndex &, int, int)), SLOT(_q_sourceRowsAboutToBeInserted(const QModelIndex &, int, int))); - connect(sourceModel, SIGNAL(rowsInserted(const QModelIndex &, int, int)), + connect(sourceModel(), SIGNAL(rowsInserted(const QModelIndex &, int, int)), SLOT(_q_sourceRowsInserted(const QModelIndex &, int, int))); - connect(sourceModel, SIGNAL(rowsAboutToBeRemoved(const QModelIndex &, int, int)), + connect(sourceModel(), SIGNAL(rowsAboutToBeRemoved(const QModelIndex &, int, int)), SLOT(_q_sourceRowsAboutToBeRemoved(const QModelIndex &, int, int))); - connect(sourceModel, SIGNAL(rowsRemoved(const QModelIndex &, int, int)), + connect(sourceModel(), SIGNAL(rowsRemoved(const QModelIndex &, int, int)), SLOT(_q_sourceRowsRemoved(const QModelIndex &, int, int))); - connect(sourceModel, SIGNAL(rowsAboutToBeMoved(const QModelIndex &, int, int, const QModelIndex &, int)), + connect(sourceModel(), SIGNAL(rowsAboutToBeMoved(const QModelIndex &, int, int, const QModelIndex &, int)), SLOT(_q_sourceRowsAboutToBeMoved(const QModelIndex &, int, int, const QModelIndex &, int))); - connect(sourceModel, SIGNAL(rowsMoved(const QModelIndex &, int, int, const QModelIndex &, int)), + connect(sourceModel(), SIGNAL(rowsMoved(const QModelIndex &, int, int, const QModelIndex &, int)), SLOT(_q_sourceRowsMoved(const QModelIndex &, int, int, const QModelIndex &, int))); - connect(sourceModel, SIGNAL(columnsAboutToBeInserted(const QModelIndex &, int, int)), + connect(sourceModel(), SIGNAL(columnsAboutToBeInserted(const QModelIndex &, int, int)), SLOT(_q_sourceColumnsAboutToBeInserted(const QModelIndex &, int, int))); - connect(sourceModel, SIGNAL(columnsInserted(const QModelIndex &, int, int)), + connect(sourceModel(), SIGNAL(columnsInserted(const QModelIndex &, int, int)), SLOT(_q_sourceColumnsInserted(const QModelIndex &, int, int))); - connect(sourceModel, SIGNAL(columnsAboutToBeRemoved(const QModelIndex &, int, int)), + connect(sourceModel(), SIGNAL(columnsAboutToBeRemoved(const QModelIndex &, int, int)), SLOT(_q_sourceColumnsAboutToBeRemoved(const QModelIndex &, int, int))); - connect(sourceModel, SIGNAL(columnsRemoved(const QModelIndex &, int, int)), + connect(sourceModel(), SIGNAL(columnsRemoved(const QModelIndex &, int, int)), SLOT(_q_sourceColumnsRemoved(const QModelIndex &, int, int))); - connect(sourceModel, SIGNAL(columnsAboutToBeMoved(const QModelIndex &, int, int, const QModelIndex &, int)), + connect(sourceModel(), SIGNAL(columnsAboutToBeMoved(const QModelIndex &, int, int, const QModelIndex &, int)), SLOT(_q_sourceColumnsAboutToBeMoved(const QModelIndex &, int, int, const QModelIndex &, int))); - connect(sourceModel, SIGNAL(columnsMoved(const QModelIndex &, int, int, const QModelIndex &, int)), + connect(sourceModel(), SIGNAL(columnsMoved(const QModelIndex &, int, int, const QModelIndex &, int)), SLOT(_q_sourceColumnsMoved(const QModelIndex &, int, int, const QModelIndex &, int))); - connect(sourceModel, SIGNAL(modelAboutToBeReset()), + connect(sourceModel(), SIGNAL(modelAboutToBeReset()), SLOT(_q_sourceModelAboutToBeReset())); - connect(sourceModel, SIGNAL(modelReset()), + connect(sourceModel(), SIGNAL(modelReset()), SLOT(_q_sourceModelReset())); - connect(sourceModel, SIGNAL(dataChanged(const QModelIndex &, const QModelIndex &)), + connect(sourceModel(), SIGNAL(dataChanged(const QModelIndex &, const QModelIndex &)), SLOT(_q_sourceDataChanged(const QModelIndex &, const QModelIndex &))); - connect(sourceModel, SIGNAL(headerDataChanged(Qt::Orientation,int,int)), + connect(sourceModel(), SIGNAL(headerDataChanged(Qt::Orientation,int,int)), SLOT(_q_sourceHeaderDataChanged(Qt::Orientation,int,int))); - connect(sourceModel, SIGNAL(layoutAboutToBeChanged()), + connect(sourceModel(), SIGNAL(layoutAboutToBeChanged()), SLOT(_q_sourceLayoutAboutToBeChanged())); - connect(sourceModel, SIGNAL(layoutChanged()), + connect(sourceModel(), SIGNAL(layoutChanged()), SLOT(_q_sourceLayoutChanged())); } |