From 0f220503ff9f0b571ce3d3f8ee5941cf344edff7 Mon Sep 17 00:00:00 2001 From: Jean-Marc Lasgouttes Date: Fri, 10 Mar 2017 15:54:27 +0100 Subject: [PATCH] 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. --- src/frontends/qt4/CategorizedCombo.cpp | 4 ++-- src/frontends/qt4/LayoutBox.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/frontends/qt4/CategorizedCombo.cpp b/src/frontends/qt4/CategorizedCombo.cpp index 8e4fc64f45..4509e79b95 100644 --- a/src/frontends/qt4/CategorizedCombo.cpp +++ b/src/frontends/qt4/CategorizedCombo.cpp @@ -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] + ""; diff --git a/src/frontends/qt4/LayoutBox.cpp b/src/frontends/qt4/LayoutBox.cpp index 09dd878b38..8945ed0959 100644 --- a/src/frontends/qt4/LayoutBox.cpp +++ b/src/frontends/qt4/LayoutBox.cpp @@ -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] + ""; -- 2.39.2