From 33c3525e38580a8333d86316ad79952359d4ac31 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Thu, 22 Sep 2011 09:20:52 +0200 Subject: [PATCH] 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 --- src/declarative/items/qsgtextedit.cpp | 2 +- src/declarative/items/qsgtextnode.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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; -- 1.7.2.5