commit c8a829d273020d10ae5a22eb8a9fabafe7b81e6e
Author: Jean-Marc Lasgouttes <[email protected]>
Date: Tue Dec 6 16:06:03 2016 +0100
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
---
src/frontends/qt4/GuiFontMetrics.cpp | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/src/frontends/qt4/GuiFontMetrics.cpp
b/src/frontends/qt4/GuiFontMetrics.cpp
index 77cda80..d3c89f1 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