diff options
author | Sean Harmer <sh@theharmers.co.uk> | 2018-10-11 09:55:11 +0000 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2018-10-11 10:52:41 +0000 |
commit | b4e52d6a8deef3d268ea97cb5e4ea14948117aad (patch) | |
tree | 11245e012864cca826b904d00725af60e7184c74 /src/extras/text/qtext2dentity.cpp | |
parent | 12c76991b8ed7378f6d2645dec8dfdd5879562b1 (diff) | |
parent | 9c40f3e4269fb0a21f3555fd6a5e99e8b4ddf1d9 (diff) |
Merge "Merge branch '5.12' into dev" into refs/staging/dev
Diffstat (limited to 'src/extras/text/qtext2dentity.cpp')
-rw-r--r-- | src/extras/text/qtext2dentity.cpp | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/src/extras/text/qtext2dentity.cpp b/src/extras/text/qtext2dentity.cpp index 10939a1e2..ae25e8ecc 100644 --- a/src/extras/text/qtext2dentity.cpp +++ b/src/extras/text/qtext2dentity.cpp @@ -92,10 +92,17 @@ void QText2DEntityPrivate::setScene(Qt3DCore::QScene *scene) // Unref old glyph cache if it exists if (m_scene != nullptr) { + // Ensure we don't keep reference to glyphs + // if we are changing the cache + if (m_glyphCache != nullptr) + clearCurrentGlyphRuns(); + m_glyphCache = nullptr; + QText2DEntityPrivate::CacheEntry &entry = QText2DEntityPrivate::m_glyphCacheInstances[m_scene]; --entry.count; if (entry.count == 0 && entry.glyphCache != nullptr) { + delete entry.glyphCache; entry.glyphCache = nullptr; } @@ -149,7 +156,6 @@ void QText2DEntityPrivate::setCurrentGlyphRuns(const QVector<QGlyphRun> &runs) // For each distinct texture, we need a separate DistanceFieldTextRenderer, // for which we need vertex and index data QHash<Qt3DRender::QAbstractTexture*, RenderData> renderData; - const float scale = computeActualScale(); // process glyph runs @@ -248,6 +254,13 @@ void QText2DEntityPrivate::setCurrentGlyphRuns(const QVector<QGlyphRun> &runs) m_currentGlyphRuns = runs; } +void QText2DEntityPrivate::clearCurrentGlyphRuns() +{ + for (int i = 0; i < m_currentGlyphRuns.size(); i++) + m_glyphCache->derefGlyphs(m_currentGlyphRuns[i]); + m_currentGlyphRuns.clear(); +} + void QText2DEntityPrivate::update() { if (m_glyphCache == nullptr) |