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); }