Fix extra selection in QML TextEdit
authorEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com>
Thu, 22 Sep 2011 07:20:52 +0000 (09:20 +0200)
committerQt by Nokia <qt-info@nokia.com>
Thu, 22 Sep 2011 07:42:43 +0000 (09:42 +0200)
QSGTextEdit::selectionEnd() interprets the selection end as the
first character after the selection, while QSGTextNode expects it
to be the end of the selection.

Task-number: QTBUG-21533
Change-Id: Ia928602f8a2f845f3990a443e62f640ea72aa1d4
Reviewed-on: http://codereview.qt-project.org/5363
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Jiang Jiang <jiang.jiang@nokia.com>
src/declarative/items/qsgtextedit.cpp
src/declarative/items/qsgtextnode.cpp

index 885fdaf..af018ae 100644 (file)
@@ -1530,7 +1530,7 @@ QSGNode *QSGTextEdit::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *upd
         QColor selectedTextColor = d->control->palette().color(QPalette::HighlightedText);
         node->addTextDocument(bounds.topLeft(), d->document, d->color, QSGText::Normal, QColor(),
                               selectionColor, selectedTextColor, selectionStart(),
-                              selectionEnd());
+                              selectionEnd() - 1);
 
 #if defined(Q_WS_MAC)
         // We also need to make sure the document layout is redone when
index 5ff8395..3af7e54 100644 (file)
@@ -663,7 +663,7 @@ namespace {
 
         bool hasSelection = selectionStart >= 0
                          && selectionEnd >= 0
-                         && selectionStart != selectionEnd;
+                         && selectionStart <= selectionEnd;
 
         QTextLine &line = m_currentLine;
         int rangeEnd = rangeStart + rangeLength;