From: Jean-Marc Lasgouttes Date: Tue, 6 Dec 2016 15:06:03 +0000 (+0100) Subject: Handle negative values gracefully. X-Git-Tag: 2.3.0alpha1~655 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=c8a829d273020d10ae5a22eb8a9fabafe7b81e6e;p=features.git Handle negative values gracefully. It may happen (for example with on the fly spell checking) that GuiFontMetrics::pos2x is called with a negative pos value. Add a special case for this situation. Fixes bug #10506 --- diff --git a/src/frontends/qt4/GuiFontMetrics.cpp b/src/frontends/qt4/GuiFontMetrics.cpp index 77cda80434..d3c89f1a59 100644 --- a/src/frontends/qt4/GuiFontMetrics.cpp +++ b/src/frontends/qt4/GuiFontMetrics.cpp @@ -205,6 +205,8 @@ GuiFontMetrics::getTextLayout(docstring const & s, QFont font, int GuiFontMetrics::pos2x(docstring const & s, int const pos, bool const rtl, double const wordspacing) const { + if (pos <= 0) + return rtl ? width(s) : 0; QTextLayout const & tl = getTextLayout(s, font_, rtl, wordspacing); /* Since QString is UTF-16 and docstring is UCS-4, the offsets may * not be the same when there are high-plan unicode characters