From dac6bad5ba411ccc4e6e5fe18250a912d7e87b9c Mon Sep 17 00:00:00 2001
From: Richard Moe Gustavsen <richard.gustavsen@digia.com>
Date: Thu, 4 Sep 2014 09:38:29 +0200
Subject: [PATCH] QQuickTextInput: calculate height of cursor rect using
 QTextLine::height()

Calculating the height of the line using ascent + descent seems
inaccurate, since the result will not match what ends up being
drawn. QQuickTextEdit uses instead QTextLine::height() for the
same function, and this works correct.
Since there seems to be no reason to reinvent how to calculate the
height when the line already has a function for that, and since the
result also seems to be wrong, we change the implementation to
use QTextLine::height().

Change-Id: I9c9cd4360b6d4cfd3582756c4efdff9c02065789
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@digia.com>
---
 src/quick/items/qquicktextinput.cpp | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/src/quick/items/qquicktextinput.cpp b/src/quick/items/qquicktextinput.cpp
index e265d04ecc..27752d53b4 100644
--- a/src/quick/items/qquicktextinput.cpp
+++ b/src/quick/items/qquicktextinput.cpp
@@ -771,8 +771,7 @@ QRectF QQuickTextInput::cursorRectangle() const
         return QRectF();
     qreal x = l.cursorToX(c) - d->hscroll;
     qreal y = l.y() - d->vscroll;
-    qreal height = l.ascent() + l.descent();
-    return QRectF(x, y, 1, height);
+    return QRectF(x, y, 1, l.height());
 }
 
 /*!
@@ -1388,8 +1387,7 @@ QRectF QQuickTextInput::positionToRectangle(int pos) const
         return QRectF();
     qreal x = l.cursorToX(pos) - d->hscroll;
     qreal y = l.y() - d->vscroll;
-    qreal height = l.ascent() + l.descent();
-    return QRectF(x, y, 1, height);
+    return QRectF(x, y, 1, l.height());
 }
 
 /*!
-- 
GitLab