Fix crash when filtering out warnings from issues pane

Do not send endRemoveRows if we never sent beginRemoveRows.
Fix up of 702d6a6914

Task-number: QTCREATORBUG-20741
Change-Id: If22a18e6426c8b4041924a170d5927ab9d11ccdf
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
This commit is contained in:
Eike Ziller
2018-07-09 09:52:09 +02:00
parent 943f499fe4
commit e152b1c468
2 changed files with 7 additions and 1 deletions

View File

@@ -337,7 +337,10 @@ TaskFilterModel::TaskFilterModel(TaskModel *sourceModel, QObject *parent) : QAbs
connect(m_sourceModel, &QAbstractItemModel::rowsRemoved, connect(m_sourceModel, &QAbstractItemModel::rowsRemoved,
this, [this](const QModelIndex &parent, int, int) { this, [this](const QModelIndex &parent, int, int) {
QTC_ASSERT(!parent.isValid(), return); QTC_ASSERT(!parent.isValid(), return);
if (m_beginRemoveRowsSent) {
m_beginRemoveRowsSent = false;
endRemoveRows(); endRemoveRows();
}
}); });
connect(m_sourceModel, &QAbstractItemModel::modelReset, connect(m_sourceModel, &QAbstractItemModel::modelReset,
@@ -430,6 +433,7 @@ void TaskFilterModel::handleNewRows(const QModelIndex &index, int first, int las
void TaskFilterModel::handleRowsAboutToBeRemoved(const QModelIndex &index, int first, int last) void TaskFilterModel::handleRowsAboutToBeRemoved(const QModelIndex &index, int first, int last)
{ {
m_beginRemoveRowsSent = false;
QTC_ASSERT(!index.isValid(), return); QTC_ASSERT(!index.isValid(), return);
const QPair<int, int> range = findFilteredRange(first, last, m_mapping); const QPair<int, int> range = findFilteredRange(first, last, m_mapping);
@@ -437,6 +441,7 @@ void TaskFilterModel::handleRowsAboutToBeRemoved(const QModelIndex &index, int f
return; return;
beginRemoveRows(QModelIndex(), range.first, range.second); beginRemoveRows(QModelIndex(), range.first, range.second);
m_beginRemoveRowsSent = true;
m_mapping.erase(m_mapping.begin() + range.first, m_mapping.begin() + range.second + 1); m_mapping.erase(m_mapping.begin() + range.first, m_mapping.begin() + range.second + 1);
const int sourceRemovedCount = (last - first) + 1; const int sourceRemovedCount = (last - first) + 1;
for (int i = range.first; i < m_mapping.count(); ++i) for (int i = range.first; i < m_mapping.count(); ++i)

View File

@@ -165,6 +165,7 @@ private:
void updateMapping() const; void updateMapping() const;
bool filterAcceptsTask(const Task &task) const; bool filterAcceptsTask(const Task &task) const;
bool m_beginRemoveRowsSent = false;
bool m_includeUnknowns; bool m_includeUnknowns;
bool m_includeWarnings; bool m_includeWarnings;
bool m_includeErrors; bool m_includeErrors;