diff options
author | Paul Lemire <paul.lemire@kdab.com> | 2023-02-10 09:47:50 +0100 |
---|---|---|
committer | Paul Lemire <paul.lemire@kdab.com> | 2023-02-13 09:00:33 +0100 |
commit | 9f2d212416c3c718a5661a09438fb413f9cc53b6 (patch) | |
tree | b8e9a9d315815c093d84694ef2ff7fd38083c4f4 /src/render/renderstates | |
parent | a7e1118103b367e4e5738104afdc7885536c7a1b (diff) |
QText2DEntity: fix QTextureAtlas parenting that could lead to crashes
We rely on a DistanceFieldFont object to manage QTextureAtlas that hold
the glyphs. The DistanceFieldFont/QTextureAtlas are supposed to be parented
by the scene root to ensure that a QTextureAtlas lives as long as possible.
DistanceFieldFont/QTextureAtlas are stored in a cache global to the scene
to minimize the use of resources.
When adding text elements, we can reuse atlases since the cache is global to
the scene and only destroy an atlas (and remove it from the cache) when we
know no more glyphs are referencing it.
However we were mistakenly passing a null parenty to DistanceFieldFont instace
of the scene root. This resulted on the QTextureAtlas not being parented by
the scene root but rather by the first DistanceFieldRenderer to use the atlas.
This meants that if the DistanceFieldRenderer were to be destroyed, so would
the atlas (yet it would still be referenced by the glyph cache leading to
crashes).
Change-Id: Id84f6a651b162a4bb3c571b11388fd2429b231de
Reviewed-by: Mike Krus <mike.krus@kdab.com>
(cherry picked from commit b1a135c547f38db0b2ce6b7bc4c4cccc43ef87d3)
Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
Diffstat (limited to 'src/render/renderstates')
0 files changed, 0 insertions, 0 deletions