From d218d8c8538e47cf32a06b4bdd9f60bd16a8cf50 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Wed, 29 Jul 2015 14:27:58 +0200 Subject: Fix selecting single character in middle of string The fix for QTBUG-46829 revealed a bug in the code to handle selecting part of ligatures. The ranges were assumed to be [start, end], while they are in fact [start, end>. This would cause the engine to assume the previous node overlapped completely with the selected node and that the node had thus already been added to the graph. Due to the bug in QTBUG-46829, this accidentally worked before, but when that bug was fixed, this bug appeared. Change-Id: I517d260de9f58db4504dd4320b7113fbbe305a81 Reviewed-by: Gunnar Sletta --- src/quick/items/qquicktextnodeengine.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/quick/items/qquicktextnodeengine.cpp') diff --git a/src/quick/items/qquicktextnodeengine.cpp b/src/quick/items/qquicktextnodeengine.cpp index 5140ccb68f..efe79b382e 100644 --- a/src/quick/items/qquicktextnodeengine.cpp +++ b/src/quick/items/qquicktextnodeengine.cpp @@ -821,14 +821,14 @@ void QQuickTextNodeEngine::addToSceneGraph(QQuickTextNode *parentNode, for (int i = 0; i < node->ranges.size(); ++i) { const QPair &range = node->ranges.at(i); - int rangeLength = range.second - range.first + 1; + int rangeLength = range.second - range.first; if (previousNode != 0) { for (int j = 0; j < previousNode->ranges.size(); ++j) { const QPair &otherRange = previousNode->ranges.at(j); - if (range.first <= otherRange.second && range.second >= otherRange.first) { + if (range.first < otherRange.second && range.second > otherRange.first) { int start = qMax(range.first, otherRange.first); int end = qMin(range.second, otherRange.second); - rangeLength -= end - start + 1; + rangeLength -= end - start; if (rangeLength == 0) break; } @@ -839,10 +839,10 @@ void QQuickTextNodeEngine::addToSceneGraph(QQuickTextNode *parentNode, for (int j = 0; j < nextNode->ranges.size(); ++j) { const QPair &otherRange = nextNode->ranges.at(j); - if (range.first <= otherRange.second && range.second >= otherRange.first) { + if (range.first < otherRange.second && range.second > otherRange.first) { int start = qMax(range.first, otherRange.first); int end = qMin(range.second, otherRange.second); - rangeLength -= end - start + 1; + rangeLength -= end - start; if (rangeLength == 0) break; } -- cgit v1.2.3