Commit 60f7e9b2 authored by Kåre Särs's avatar Kåre Särs
Browse files

S&R: Fix assert when no result is selected

It is OK to pass an invalid QModelIndex to isMatch(), nextMatch(),
prevMatch()
parent 4d9c0c59
Pipeline #130776 passed with stage
in 3 minutes and 34 seconds
......@@ -80,7 +80,7 @@ bool Results::isEmpty() const
bool Results::isMatch(const QModelIndex &index) const
{
Q_ASSERT(index.model() == model());
Q_ASSERT(!index.isValid() || index.model() == model());
return matchModel.isMatch(model()->mapToSource(index));
}
......@@ -101,13 +101,13 @@ QModelIndex Results::firstMatch() const
QModelIndex Results::nextMatch(const QModelIndex &itemIndex) const
{
Q_ASSERT(itemIndex.model() == model());
Q_ASSERT(!itemIndex.isValid() || itemIndex.model() == model());
return model()->mapFromSource(matchModel.nextMatch(model()->mapToSource(itemIndex)));
}
QModelIndex Results::prevMatch(const QModelIndex &itemIndex) const
{
Q_ASSERT(itemIndex.model() == model());
Q_ASSERT(!itemIndex.isValid() || itemIndex.model() == model());
return model()->mapFromSource(matchModel.prevMatch(model()->mapToSource(itemIndex)));
}
......
......@@ -1342,7 +1342,7 @@ void KatePluginSearchView::replaceSingleMatch()
}
QModelIndex itemIndex = res->treeView->currentIndex();
if (!res->isMatch(itemIndex)) {
if (!itemIndex.isValid() || !res->isMatch(itemIndex)) {
goToNextMatch();
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment