diff options
author | Lars Knoll <lars.knoll@qt.io> | 2018-11-05 13:19:49 +0100 |
---|---|---|
committer | Liang Qi <liang.qi@qt.io> | 2018-11-14 20:16:31 +0000 |
commit | c3d2d83fcb0f88de7d08cb7d088db8942e2e0f64 (patch) | |
tree | 88d48ccc191308451f6109bd597738ad49dba46c /src | |
parent | 800cd53c7e7c34571582d463c3f40de4df908818 (diff) |
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 <allan.jensen@qt.io>
Diffstat (limited to 'src')
-rw-r--r-- | src/gui/text/qtextengine.cpp | 21 |
1 files changed, 13 insertions, 8 deletions
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<QTextEngine *>(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); } |