Fix bug which caused repeated characters in a QML Text
authorEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com>
Mon, 20 Jun 2011 08:45:36 +0000 (10:45 +0200)
committerQt Continuous Integration System <qt-info@nokia.com>
Mon, 20 Jun 2011 11:08:48 +0000 (13:08 +0200)
We would include too much in the characters displayed, since
itemEnd is actually the start of the next item and not the
end of the current one. Adding a minus one removes the duplicated
characters at the end of text lines.

Change-Id: I1e13470548fafaa692ae58e019e9e2469a947f5e
Reviewed-on: http://codereview.qt.nokia.com/495
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Gunnar Sletta <gunnar.sletta@nokia.com>
src/gui/text/qtextlayout.cpp

index 781dd23..f9bfcbf 100644 (file)
@@ -2151,7 +2151,7 @@ QList<QGlyphRun> QTextLine::glyphRuns(int from, int length) const
         }
 
         int relativeFrom = qMax(iterator.itemStart, from) - si.position;
-        int relativeTo = qMin(iterator.itemEnd, from + length - 1) - si.position;
+        int relativeTo = qMin(iterator.itemEnd - 1, from + length - 1) - si.position;
 
         unsigned short *logClusters = eng->logClusters(&si);
         int glyphsStart = logClusters[relativeFrom];
@@ -2170,7 +2170,7 @@ QList<QGlyphRun> QTextLine::glyphRuns(int from, int length) const
                 pos += QPointF((glyphLayout.advances_x[i] + justification).toReal(),
                                glyphLayout.advances_y[i].toReal());
             }
-        } else if (relativeTo != (iterator.itemEnd - si.position) && rtl) {
+        } else if (relativeTo != (iterator.itemEnd - si.position - 1) && rtl) {
             for (int i=glyphLayout.numGlyphs - 1; i>glyphsEnd; --i) {
                 QFixed justification = QFixed::fromFixed(glyphLayout.justifications[i].space_18d6);
                 pos += QPointF((glyphLayout.advances_x[i] + justification).toReal(),