gpu: Fix texture eviction

If we gc a cached texture for which the GdkTexture is still alive,
the cached texture object will remain accessible via the render
data, so need to make sure not to leave a dangling pointer behind
here.
This commit is contained in:
Matthias Clasen 2024-01-19 12:43:37 -05:00
parent bd9ea05ebb
commit 4d92093c67

View File

@ -200,8 +200,8 @@ gsk_gpu_cached_texture_free (GskGpuDevice *device,
gboolean texture_still_alive;
texture_still_alive = g_atomic_pointer_exchange (&self->texture, NULL) != NULL;
g_object_unref (self->image);
g_clear_object (&self->image);
if (!texture_still_alive)
g_free (self);
}
@ -663,10 +663,8 @@ gsk_gpu_device_lookup_texture_image (GskGpuDevice *self,
if (cache == NULL)
cache = g_hash_table_lookup (priv->texture_cache, texture);
if (cache)
{
return g_object_ref (cache->image);
}
if (cache && cache->image)
return g_object_ref (cache->image);
return NULL;
}