]> git.lyx.org Git - features.git/commitdiff
Small cleanup to LayoutBox and CategorizedCombo
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Fri, 10 Mar 2017 14:54:27 +0000 (15:54 +0100)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Fri, 10 Mar 2017 14:57:31 +0000 (15:57 +0100)
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
src/frontends/qt4/LayoutBox.cpp

index 8e4fc64f4596f07bad7d6c9f17118c9febbf2126..4509e79b9566c28a5531ce748cbb5a1818645dc5 100644 (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>";
index 09dd878b38f34e210327befb773a2ecd60b4ed80..8945ed0959a55f11129371331578626c30075e49 100644 (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>";