summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarlos Garnacho <carlosg@gnome.org>2021-02-12 23:10:25 +0100
committerCarlos Garnacho <carlosg@gnome.org>2021-02-12 23:13:21 +0100
commit0d7a84f1b8df195ebc716ab92c68ad0b8cd1482d (patch)
treef6985479ec95336366628405b03729fa06277624
parent2beca14b8d4b4aaf7a656b5cab332986dae304ba (diff)
downloadgnome-shell-wip/carlosg/weak-ref-source.tar.gz
st: Keep weak ref on texture cache bound texture sourcewip/carlosg/weak-ref-source
We don't keep any ref on it, so it might leave us with a dangling pointer here. Fixes: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/3491
-rw-r--r--src/st/st-texture-cache.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/st/st-texture-cache.c b/src/st/st-texture-cache.c
index 89620706c..07b1166a1 100644
--- a/src/st/st-texture-cache.c
+++ b/src/st/st-texture-cache.c
@@ -798,6 +798,10 @@ st_texture_cache_bind_weak_notify (gpointer data,
{
StTextureCachePropertyBind *bind = data;
bind->weakref_active = FALSE;
+ if (G_OBJECT (bind->image) != source_location)
+ g_object_weak_unref (G_OBJECT (bind->image), st_texture_cache_bind_weak_notify, bind);
+ if (bind->source != source_location)
+ g_object_weak_unref (G_OBJECT (bind->source), st_texture_cache_bind_weak_notify, bind);
g_signal_handler_disconnect (bind->source, bind->notify_signal_id);
}
@@ -805,8 +809,13 @@ static void
st_texture_cache_free_bind (gpointer data)
{
StTextureCachePropertyBind *bind = data;
+
if (bind->weakref_active)
- g_object_weak_unref (G_OBJECT (bind->image), st_texture_cache_bind_weak_notify, bind);
+ {
+ g_object_weak_unref (G_OBJECT (bind->image), st_texture_cache_bind_weak_notify, bind);
+ g_object_weak_unref (G_OBJECT (bind->source), st_texture_cache_bind_weak_notify, bind);
+ }
+
g_free (bind);
}
@@ -840,6 +849,7 @@ st_texture_cache_bind_cairo_surface_property (StTextureCache *cache,
st_texture_cache_reset_texture (bind, property_name);
g_object_weak_ref (G_OBJECT (bind->image), st_texture_cache_bind_weak_notify, bind);
+ g_object_weak_ref (G_OBJECT (bind->source), st_texture_cache_bind_weak_notify, bind);
bind->weakref_active = TRUE;
notify_key = g_strdup_printf ("notify::%s", property_name);