From: Eskil Abrahamsen Blomfeldt Date: Thu, 22 Sep 2011 07:20:52 +0000 (+0200) Subject: Fix extra selection in QML TextEdit X-Git-Url: http://git.silmor.de/gitweb/?a=commitdiff_plain;h=33c3525e38580a8333d86316ad79952359d4ac31;p=konrad%2Fqtdeclarative.git Fix extra selection in QML TextEdit 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 Reviewed-by: Jiang Jiang --- diff --git a/src/declarative/items/qsgtextedit.cpp b/src/declarative/items/qsgtextedit.cpp index 885fdaf..af018ae 100644 --- a/src/declarative/items/qsgtextedit.cpp +++ b/src/declarative/items/qsgtextedit.cpp @@ -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 diff --git a/src/declarative/items/qsgtextnode.cpp b/src/declarative/items/qsgtextnode.cpp index 5ff8395..3af7e54 100644 --- a/src/declarative/items/qsgtextnode.cpp +++ b/src/declarative/items/qsgtextnode.cpp @@ -663,7 +663,7 @@ namespace { bool hasSelection = selectionStart >= 0 && selectionEnd >= 0 - && selectionStart != selectionEnd; + && selectionStart <= selectionEnd; QTextLine &line = m_currentLine; int rangeEnd = rangeStart + rangeLength;