Small cleanup to LayoutBox and CategorizedCombo

Coverity does not find it obvious that p is never negative. Normally
it is the case (because the items have been filtered), but it is
better to play safe.
This commit is contained in:
Jean-Marc Lasgouttes 2017-03-10 15:54:27 +01:00
parent c99e2f1fad
commit 0f220503ff
2 changed files with 4 additions and 4 deletions

View File

@ -271,10 +271,10 @@ QString CCItemDelegate::underlineFilter(QString const & s) const
// step through data item and put "(x)" for every matching character
QString r;
int lastp = -1;
cc_->filter();
for (int i = 0; i < f.length(); ++i) {
int p = s.indexOf(f[i], lastp + 1, Qt::CaseInsensitive);
LASSERT(p != -1, /**/);
if (p < 0)
continue;
if (lastp == p - 1 && lastp != -1) {
// remove ")" and append "x)"
r = r.left(r.length() - 4) + s[p] + "</u>";

View File

@ -320,10 +320,10 @@ QString LayoutItemDelegate::underlineFilter(QString const & s) const
// step through data item and put "(x)" for every matching character
QString r;
int lastp = -1;
layout_->filter();
for (int i = 0; i < f.length(); ++i) {
int p = s.indexOf(f[i], lastp + 1, Qt::CaseInsensitive);
LASSERT(p != -1, continue);
if (p < 0)
continue;
if (lastp == p - 1 && lastp != -1) {
// remove ")" and append "x)"
r = r.left(r.length() - 4) + s[p] + "</u>";