From e9fb5c1669654adbfc7a73c6385df17aef34905b Mon Sep 17 00:00:00 2001 From: Jarek Kobus Date: Tue, 14 Mar 2017 13:41:30 +0100 Subject: Fix setting a source model in BookmarkFilterModel Pass newly set model to the QAbstractProxyModel::setSourceModel() call, instead of the old model. Make sure the new model is not null. Change-Id: I149b3c6defd070eb7f6f6fd068639ebf784dfcb9 Reviewed-by: Karsten Heimrich --- src/assistant/assistant/bookmarkfiltermodel.cpp | 36 ++++++++++++------------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/src/assistant/assistant/bookmarkfiltermodel.cpp b/src/assistant/assistant/bookmarkfiltermodel.cpp index 055272532..d0078840d 100644 --- a/src/assistant/assistant/bookmarkfiltermodel.cpp +++ b/src/assistant/assistant/bookmarkfiltermodel.cpp @@ -60,32 +60,32 @@ void BookmarkFilterModel::setSourceModel(QAbstractItemModel *_sourceModel) disconnect(sourceModel, SIGNAL(modelReset()), this, SLOT(modelReset())); } - QAbstractProxyModel::setSourceModel(sourceModel); sourceModel = qobject_cast (_sourceModel); + QAbstractProxyModel::setSourceModel(sourceModel); - connect(sourceModel, SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, - SLOT(changed(QModelIndex,QModelIndex))); + if (sourceModel) { + connect(sourceModel, SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, + SLOT(changed(QModelIndex,QModelIndex))); - connect(sourceModel, SIGNAL(rowsInserted(QModelIndex,int,int)), - this, SLOT(rowsInserted(QModelIndex,int,int))); + connect(sourceModel, SIGNAL(rowsInserted(QModelIndex,int,int)), + this, SLOT(rowsInserted(QModelIndex,int,int))); - connect(sourceModel, SIGNAL(rowsAboutToBeRemoved(QModelIndex,int,int)), - this, SLOT(rowsAboutToBeRemoved(QModelIndex,int,int))); - connect(sourceModel, SIGNAL(rowsRemoved(QModelIndex,int,int)), this, - SLOT(rowsRemoved(QModelIndex,int,int))); + connect(sourceModel, SIGNAL(rowsAboutToBeRemoved(QModelIndex,int,int)), + this, SLOT(rowsAboutToBeRemoved(QModelIndex,int,int))); + connect(sourceModel, SIGNAL(rowsRemoved(QModelIndex,int,int)), this, + SLOT(rowsRemoved(QModelIndex,int,int))); - connect(sourceModel, SIGNAL(layoutAboutToBeChanged()), this, - SLOT(layoutAboutToBeChanged())); - connect(sourceModel, SIGNAL(layoutChanged()), this, - SLOT(layoutChanged())); + connect(sourceModel, SIGNAL(layoutAboutToBeChanged()), this, + SLOT(layoutAboutToBeChanged())); + connect(sourceModel, SIGNAL(layoutChanged()), this, + SLOT(layoutChanged())); - connect(sourceModel, SIGNAL(modelAboutToBeReset()), this, - SLOT(modelAboutToBeReset())); - connect(sourceModel, SIGNAL(modelReset()), this, SLOT(modelReset())); + connect(sourceModel, SIGNAL(modelAboutToBeReset()), this, + SLOT(modelAboutToBeReset())); + connect(sourceModel, SIGNAL(modelReset()), this, SLOT(modelReset())); - if (sourceModel) setupCache(sourceModel->index(0, 0, QModelIndex()).parent()); - + } endResetModel(); } -- cgit v1.2.1