aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick
diff options
context:
space:
mode:
authorPierre Rossi <pierre.rossi@digia.com>2013-03-25 16:52:45 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-04-24 14:12:01 +0200
commit159ccaa57f6f653c36af47910b98e106be5112bc (patch)
treee5dd481212528e35cfa804732f67df047e200e5f /src/quick
parenta16f3c660b3a28e011b38bd63de36e801821e56c (diff)
QQuickTextEdit: make the update logic work with multiple text frames
We can't assume that the text nodes are added in order since we're iterating over all the blocks of a text frame before processing its child text frames. The only way for all this not to collapse is to sort the text nodes once we're done each time we're replacing/adding new ones. Task-number: QTBUG-30349 Change-Id: Ia5d804f7f196b2348fd68fdd62a6585c189baaa4 Reviewed-by: Caroline Chao <caroline.chao@digia.com> Reviewed-by: Jens Bache-Wiig <jens.bache-wiig@digia.com> Reviewed-by: Alan Alpert <aalpert@blackberry.com>
Diffstat (limited to 'src/quick')
-rw-r--r--src/quick/items/qquicktextedit.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/quick/items/qquicktextedit.cpp b/src/quick/items/qquicktextedit.cpp
index dde3587018..2facb9846d 100644
--- a/src/quick/items/qquicktextedit.cpp
+++ b/src/quick/items/qquicktextedit.cpp
@@ -1805,14 +1805,13 @@ QSGNode *QQuickTextEdit::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *
transformMatrix.translate(nodeOffset.x(), nodeOffset.y());
node->setMatrix(transformMatrix);
}
-
node->m_engine->addTextBlock(d->document, block, basePosition - nodeOffset, d->color, QColor(), selectionStart(), selectionEnd() - 1);
sizeCounter += block.length();
if ((it.atEnd() && frames.isEmpty()) || (firstCleanNode && block.next().position() >= firstCleanNode->startPos())) // last node that needed replacing or last block of the last frame
break;
- if (sizeCounter > nodeBreakingSize) {
+ if (sizeCounter > nodeBreakingSize || it.atEnd()) { // text block grouping across text frames might not be a good idea, split it.
sizeCounter = 0;
node->m_engine->addToSceneGraph(node, QQuickText::Normal, QColor());
nodeIterator = d->textNodeMap.insert(nodeIterator, new TextNode(prevBlockStart, node));
@@ -1848,6 +1847,10 @@ QSGNode *QQuickTextEdit::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *
}
}
+
+ // Since we iterate over blocks from different text frames that are potentially not sorted
+ // we need to ensure that our list of nodes is sorted again:
+ std::sort(d->textNodeMap.begin(), d->textNodeMap.end(), &comesBefore);
}
if (d->cursorComponent == 0 && !isReadOnly()) {