summaryrefslogtreecommitdiffstats
path: root/src/extras/text/qtext2dentity.cpp
diff options
context:
space:
mode:
authorQt Forward Merge Bot <qt_forward_merge_bot@qt-project.org>2018-10-05 13:58:50 +0200
committerQt Forward Merge Bot <qt_forward_merge_bot@qt-project.org>2018-10-05 13:58:50 +0200
commit6c77dea4711b6a88e80e30db21d622808e5ef9b6 (patch)
tree7f03934b19f5782447da135aeceb4269298e3f2a /src/extras/text/qtext2dentity.cpp
parentedc88e97721c0a223a2b77cec217f550f08a4135 (diff)
parentd8789d8fd17fd58f06003e9846b3d107ffc8ec52 (diff)
Merge remote-tracking branch 'origin/5.11' into 5.12
Diffstat (limited to 'src/extras/text/qtext2dentity.cpp')
-rw-r--r--src/extras/text/qtext2dentity.cpp15
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)