summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVolker Enderlein <volker.enderlein@ifm-chemnitz.de>2019-12-06 13:01:16 +0100
committerVolker Enderlein <volker.enderlein@ifm-chemnitz.de>2019-12-13 13:23:41 +0100
commit1cb7458af3ca427f2d25f939044b10e037740db3 (patch)
tree7ccbb2617abc57cfd7ebb2574d568b3a1f32f7c3
parent54535dec77e0855ba8268512399ad6f87c25adce (diff)
QText2DEntity: Support display of empty strings
The DistantFieldTextRenderer of a QText2DEntity was not properly updated for empty strings. The dereferencing of previous QGlyphRuns needs to be done before the number of DistantFieldTextRenderers is adjusted as a DistandFieldTextRenderer may be the parent of a QTextureAtlas that is referenced by a Glyph. Task-number: QTBUG-80569 Change-Id: I0dba8b749148bef088864dc7200ae0513965745a Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
-rw-r--r--src/extras/text/qtext2dentity.cpp13
1 files changed, 5 insertions, 8 deletions
diff --git a/src/extras/text/qtext2dentity.cpp b/src/extras/text/qtext2dentity.cpp
index aa4785fe7..897672782 100644
--- a/src/extras/text/qtext2dentity.cpp
+++ b/src/extras/text/qtext2dentity.cpp
@@ -217,9 +217,6 @@ struct RenderData {
void QText2DEntityPrivate::setCurrentGlyphRuns(const QVector<QGlyphRun> &runs)
{
- if (runs.isEmpty())
- return;
-
// For each distinct texture, we need a separate DistanceFieldTextRenderer,
// for which we need vertex and index data
QHash<Qt3DRender::QAbstractTexture*, RenderData> renderData;
@@ -294,6 +291,11 @@ void QText2DEntityPrivate::setCurrentGlyphRuns(const QVector<QGlyphRun> &runs)
}
}
+ // de-ref all glyphs for previous QGlyphRuns
+ for (int i = 0; i < m_currentGlyphRuns.size(); i++)
+ m_glyphCache->derefGlyphs(m_currentGlyphRuns[i]);
+ m_currentGlyphRuns = runs;
+
// make sure we have the correct number of DistanceFieldTextRenderers
// TODO: we might keep one renderer at all times, so we won't delete and
// re-allocate one every time the text changes from an empty to a non-empty string
@@ -314,11 +316,6 @@ void QText2DEntityPrivate::setCurrentGlyphRuns(const QVector<QGlyphRun> &runs)
for (auto it = renderData.begin(); it != renderData.end(); ++it) {
m_renderers[rendererIdx++]->setGlyphData(it.key(), it.value().vertex, it.value().index);
}
-
- // de-ref all glyphs for previous QGlyphRuns
- for (int i = 0; i < m_currentGlyphRuns.size(); i++)
- m_glyphCache->derefGlyphs(m_currentGlyphRuns[i]);
- m_currentGlyphRuns = runs;
}
void QText2DEntityPrivate::clearCurrentGlyphRuns()