diff options
author | Paul Lemire <paul.lemire@kdab.com> | 2023-02-13 07:46:07 +0100 |
---|---|---|
committer | Paul Lemire <paul.lemire@kdab.com> | 2023-02-14 07:39:46 +0100 |
commit | b7e398620a5b467e5205722da5314938d1430f8e (patch) | |
tree | ed39b306d785db76868af7ecd01242460f0722c4 /src | |
parent | 7c853a3aa742a9500266e9e41b6702f05ae1a297 (diff) |
QDistanceFieldCache: fix QTextureAtlas dangling pointer
Note: already merged in 5.15
Pick-to: 6.5 6.4 6.2
Change-Id: If968714f1ca4869e9c607224b537e355b4a6f0dd
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/extras/text/qdistancefieldglyphcache.cpp | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/extras/text/qdistancefieldglyphcache.cpp b/src/extras/text/qdistancefieldglyphcache.cpp index 3c0ab4d16..1294cf53a 100644 --- a/src/extras/text/qdistancefieldglyphcache.cpp +++ b/src/extras/text/qdistancefieldglyphcache.cpp @@ -162,13 +162,14 @@ StoredGlyph DistanceFieldFont::refGlyph(quint32 glyph) // scenarios const int size = m_doubleGlyphResolution ? 512 : 256; - QTextureAtlas *atlas = new QTextureAtlas(m_parentNode); + QTextureAtlas *atlas = new QTextureAtlas(); atlas->setWidth(size); atlas->setHeight(size); atlas->setFormat(Qt3DRender::QAbstractTexture::R8_UNorm); atlas->setPixelFormat(QOpenGLTexture::Red); atlas->setMinificationFilter(Qt3DRender::QAbstractTexture::Linear); atlas->setMagnificationFilter(Qt3DRender::QAbstractTexture::Linear); + atlas->setParent(m_parentNode); m_atlasses << atlas; if (!storedGlyph.addToTextureAtlas(atlas)) @@ -201,7 +202,12 @@ void DistanceFieldFont::derefGlyph(quint32 glyph) Q_ASSERT(m_atlasses.contains(atlas)); m_atlasses.removeAll(atlas); - delete atlas; + + // This function might have been called as a result of destroying + // the scene root which traverses the entire scene tree. Calling + // delete on the atlas here could lead to dangling pointers in the + // least of children being traversed for destruction. + atlas->deleteLater(); } m_glyphs.erase(it); |