From 8d1e87c790f7ea1d28bc290a95c9eec67a13476a Mon Sep 17 00:00:00 2001 From: Tobias Hunger Date: Fri, 5 Oct 2012 14:32:40 +0200 Subject: [PATCH] Fix possible crash The filter model needs to remove rows before the view tries to find the next row to select. Otherwise the filtermodel might access the source model at a position that is out of bounds. Change-Id: Id610455f32e7c7fe921c243537def0097b46a798 Reviewed-by: Daniel Teske --- src/plugins/projectexplorer/taskmodel.cpp | 6 +++--- src/plugins/projectexplorer/taskmodel.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/plugins/projectexplorer/taskmodel.cpp b/src/plugins/projectexplorer/taskmodel.cpp index 89102ea2599..b4b3a8be788 100644 --- a/src/plugins/projectexplorer/taskmodel.cpp +++ b/src/plugins/projectexplorer/taskmodel.cpp @@ -345,8 +345,8 @@ TaskFilterModel::TaskFilterModel(TaskModel *sourceModel, QObject *parent) : QAbs Q_ASSERT(m_sourceModel); connect(m_sourceModel, SIGNAL(rowsInserted(QModelIndex,int,int)), this, SLOT(handleNewRows(QModelIndex,int,int))); - connect(m_sourceModel, SIGNAL(rowsRemoved(QModelIndex,int,int)), - this, SLOT(handleRemovedRows(QModelIndex,int,int))); + connect(m_sourceModel, SIGNAL(rowsAboutToBeRemoved(QModelIndex,int,int)), + this, SLOT(handleRowsAboutToBeRemoved(QModelIndex,int,int))); connect(m_sourceModel, SIGNAL(modelReset()), this, SLOT(handleReset())); connect(m_sourceModel, SIGNAL(dataChanged(QModelIndex,QModelIndex)), @@ -434,7 +434,7 @@ void TaskFilterModel::handleNewRows(const QModelIndex &index, int first, int las endInsertRows(); } -void TaskFilterModel::handleRemovedRows(const QModelIndex &index, int first, int last) +void TaskFilterModel::handleRowsAboutToBeRemoved(const QModelIndex &index, int first, int last) { if (index.isValid()) return; diff --git a/src/plugins/projectexplorer/taskmodel.h b/src/plugins/projectexplorer/taskmodel.h index bc81915c02d..81953c7f6a5 100644 --- a/src/plugins/projectexplorer/taskmodel.h +++ b/src/plugins/projectexplorer/taskmodel.h @@ -164,7 +164,7 @@ public: QModelIndex mapFromSource(const QModelIndex &idx) const; private slots: void handleNewRows(const QModelIndex &index, int first, int last); - void handleRemovedRows(const QModelIndex &index, int first, int last); + void handleRowsAboutToBeRemoved(const QModelIndex &index, int first, int last); void handleDataChanged(QModelIndex,QModelIndex bottom); void handleReset();