From c318fceaccb1ee23a567f1bb032df45417217e09 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Wed, 29 Jul 2015 13:47:45 +0200 Subject: Fix disappearing selection spanning different scripts Due to the way itemization is currently done in Qt, Cyrillic text (and other writing systems) separated by spaces will become separate items because the spaces are itemized as Script_Common. In the Scenegraph's text node engine, we should merge these items into a single node as long as the same font is used for all the text. But a bug in the engine caused this to fail when the text was selected. The symptom of this was that in some rare cases one of the items would vanish if it were in the middle of a selection. In order to support the bearing of selected text leaning outside the selection rect, I previously added a hack which would add all selected text as unselected text as well in b0783c21fb54b939f07ddf5658cc51113b8014e6. This was an awkward way of doing it and caused said regression. A less intrusive way is just to add the text to the scene graph twice, as this does not interfere with the logic needed to support selecting part of ligatures nor the engine's ability to merge nodes correctly. [ChangeLog][Text] Fixed regression with selections spanning different scripts. Task-number: QTBUG-46829 Change-Id: I0faed76fb2cd1ac0b2e5cc54b81008b5e2550733 Reviewed-by: Gunnar Sletta --- src/quick/items/qquicktextnodeengine.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'src/quick/items/qquicktextnodeengine.cpp') diff --git a/src/quick/items/qquicktextnodeengine.cpp b/src/quick/items/qquicktextnodeengine.cpp index 7903f79e89..5140ccb68f 100644 --- a/src/quick/items/qquicktextnodeengine.cpp +++ b/src/quick/items/qquicktextnodeengine.cpp @@ -596,7 +596,6 @@ void QQuickTextNodeEngine::addGlyphsInRange(int rangeStart, int rangeLength, for (int j=0; jaddRectangleNode(rect, color); } - // Add all unselected text first + // Add all text with unselected color first for (int i = 0; i < nodes.size(); ++i) { const BinaryTreeNode *node = nodes.at(i); - if (node->selectionState == Unselected) - parentNode->addGlyphs(node->position, node->glyphRun, node->color, style, styleColor, 0); + parentNode->addGlyphs(node->position, node->glyphRun, node->color, style, styleColor, 0); } for (int i = 0; i < imageNodes.size(); ++i) { -- cgit v1.2.3