From fb4f210430377e29d952d0fcf4021d80e344f162 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Fri, 19 Jan 2024 17:45:28 -0500 Subject: [PATCH] gpu: Fix ordering problem in clear_cache() We must free the glyphs before their atlases, since we now maintain the item count of the atlas when glyphs are freed. --- gsk/gpu/gskgpudevice.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/gsk/gpu/gskgpudevice.c b/gsk/gpu/gskgpudevice.c index 7c03dfc4e2..ad3a0ef0ac 100644 --- a/gsk/gpu/gskgpudevice.c +++ b/gsk/gpu/gskgpudevice.c @@ -408,8 +408,9 @@ gsk_gpu_device_clear_cache (GskGpuDevice *self) g_assert (cached->next->prev == cached); } - while (priv->first_cached) - gsk_gpu_cached_free (self, priv->first_cached); + /* We clear the cache from the end so glyphs get freed before their atlas */ + while (priv->last_cached) + gsk_gpu_cached_free (self, priv->last_cached); g_assert (priv->last_cached == NULL); }