QQuickTextInput: keep floating point precition when calculating offset
authorRichard Moe Gustavsen <richard.gustavsen@digia.com>
Wed, 3 Sep 2014 12:55:59 +0000 (14:55 +0200)
committerRichard Moe Gustavsen <richard.gustavsen@digia.com>
Thu, 4 Sep 2014 07:47:55 +0000 (09:47 +0200)
Without this patch, positionToRectangle will return a slightly
different rectangle than what ends up being drawn.

Change-Id: Ib1a3936f0fab393d6016d85d63547ec7f3036b7a
Reviewed-by: Andrew den Exter <andrew.den.exter@qinetic.com.au>
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@digia.com>
src/quick/items/qquicktextinput.cpp

index c91b79d..e265d04 100644 (file)
@@ -1868,9 +1868,9 @@ QSGNode *QQuickTextInput::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData
         if (d->autoScroll && d->m_textLayout.lineCount() > 0) {
             QFontMetricsF fm(d->font);
             // the y offset is there to keep the baseline constant in case we have script changes in the text.
-            offset = -QPoint(d->hscroll, d->vscroll + d->m_textLayout.lineAt(0).ascent() - fm.ascent());
+            offset = -QPointF(d->hscroll, d->vscroll + d->m_textLayout.lineAt(0).ascent() - fm.ascent());
         } else {
-            offset = -QPoint(d->hscroll, d->vscroll);
+            offset = -QPointF(d->hscroll, d->vscroll);
         }
 
         if (!d->m_textLayout.text().isEmpty()