Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Utilities
Kate
Commits
60f7e9b2
Commit
60f7e9b2
authored
Jan 30, 2022
by
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
Changes
2
Pipelines
3
Hide whitespace changes
Inline
Side-by-side
addons/search/Results.cpp
View file @
60f7e9b2
...
...
@@ -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
)));
}
...
...
addons/search/plugin_search.cpp
View file @
60f7e9b2
...
...
@@ -1342,7 +1342,7 @@ void KatePluginSearchView::replaceSingleMatch()
}
QModelIndex
itemIndex
=
res
->
treeView
->
currentIndex
();
if
(
!
res
->
isMatch
(
itemIndex
))
{
if
(
!
itemIndex
.
isValid
()
||
!
res
->
isMatch
(
itemIndex
))
{
goToNextMatch
();
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment