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>
This commit is contained in:
Lars Knoll 2018-11-05 13:19:49 +01:00 committed by Liang Qi
parent 800cd53c7e
commit c3d2d83fcb

View File

@ -1962,19 +1962,24 @@ const QCharAttributes *QTextEngine::attributes() const
void QTextEngine::shape(int item) 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); ensureSpace(1);
if (block.docHandle()) { if (block.docHandle()) {
docLayout()->resizeInlineObject(QTextInlineObject(item, const_cast<QTextEngine *>(this)), docLayout()->resizeInlineObject(QTextInlineObject(item, const_cast<QTextEngine *>(this)),
layoutData->items[item].position + block.position(), li.position + block.position(),
format(&layoutData->items[item])); 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 // set up at least the ascent/descent/leading of the script item for the tab
fontEngine(layoutData->items[item], fontEngine(li, &li.ascent, &li.descent, &li.leading);
&layoutData->items[item].ascent, // see the comment above
&layoutData->items[item].descent, ushort *lc = logClusters(&li);
&layoutData->items[item].leading); *lc = item ? lc[-1] : 0;
} else { } else {
shapeText(item); shapeText(item);
} }