From c3d2d83fcb0f88de7d08cb7d088db8942e2e0f64 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Mon, 5 Nov 2018 13:19:49 +0100 Subject: Correctly initialize the logClusters array for tabs and objects The logclusters where never correctly initialized for tabs or inline objects. Change-Id: I376fd2dba19994eb5add24cdb8a93c38bde8cd1e Fixes: QTBUG-70946 Reviewed-by: Allan Sandfeld Jensen --- src/gui/text/qtextengine.cpp | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/gui/text/qtextengine.cpp b/src/gui/text/qtextengine.cpp index 4e9b00f9c9..8de16038ad 100644 --- a/src/gui/text/qtextengine.cpp +++ b/src/gui/text/qtextengine.cpp @@ -1962,19 +1962,24 @@ const QCharAttributes *QTextEngine::attributes() const void QTextEngine::shape(int item) const { - if (layoutData->items.at(item).analysis.flags == QScriptAnalysis::Object) { + auto &li = layoutData->items[item]; + if (li.analysis.flags == QScriptAnalysis::Object) { ensureSpace(1); if (block.docHandle()) { docLayout()->resizeInlineObject(QTextInlineObject(item, const_cast(this)), - layoutData->items[item].position + block.position(), - format(&layoutData->items[item])); + li.position + block.position(), + format(&li)); } - } else if (layoutData->items.at(item).analysis.flags == QScriptAnalysis::Tab) { + // fix log clusters to point to the previous glyph, as the object doesn't have a glyph of it's own. + // This is required so that all entries in the array get initialized and are ordered correctly. + ushort *lc = logClusters(&li); + *lc = item ? lc[-1] : 0; + } else if (li.analysis.flags == QScriptAnalysis::Tab) { // set up at least the ascent/descent/leading of the script item for the tab - fontEngine(layoutData->items[item], - &layoutData->items[item].ascent, - &layoutData->items[item].descent, - &layoutData->items[item].leading); + fontEngine(li, &li.ascent, &li.descent, &li.leading); + // see the comment above + ushort *lc = logClusters(&li); + *lc = item ? lc[-1] : 0; } else { shapeText(item); } -- cgit v1.2.3