summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2016-01-24 12:07:25 -0500
committerMatthias Clasen <mclasen@redhat.com>2016-01-26 21:15:29 -0500
commitf32c389194289633e3569f4dcf5c728e73981cbd (patch)
treeeb23f3d4895bfbdcab420ab1a2579820ed1ee486
parentbe70c67c7697c356561ea94199594daefe1adca2 (diff)
downloadgnome-desktop-f32c389194289633e3569f4dcf5c728e73981cbd.tar.gz
thumbnail factory: Disconnect signal handlers in finalize
We are seeing crashes in Fedora that point at the settings signal handlers getting run after the thumbnail factory is finalized. Explicitly disconnecting the handlers in finalize is the right thing to do, anyway. While we are at it, replace some of the cleanup code in finalize with g_clear_pointer and g_clear_object, as suggested by Colin. https://bugzilla.gnome.org/show_bug.cgi?id=761049
-rw-r--r--libgnome-desktop/gnome-desktop-thumbnail.c89
1 files changed, 43 insertions, 46 deletions
diff --git a/libgnome-desktop/gnome-desktop-thumbnail.c b/libgnome-desktop/gnome-desktop-thumbnail.c
index cc78d93d..b2d3b31d 100644
--- a/libgnome-desktop/gnome-desktop-thumbnail.c
+++ b/libgnome-desktop/gnome-desktop-thumbnail.c
@@ -581,52 +581,6 @@ _gdk_pixbuf_new_from_uri_at_scale (const char *uri,
return pixbuf;
}
-static void
-gnome_desktop_thumbnail_factory_finalize (GObject *object)
-{
- GnomeDesktopThumbnailFactory *factory;
- GnomeDesktopThumbnailFactoryPrivate *priv;
-
- factory = GNOME_DESKTOP_THUMBNAIL_FACTORY (object);
-
- priv = factory->priv;
-
- if (priv->thumbnailers)
- {
- g_list_free_full (priv->thumbnailers, (GDestroyNotify)thumbnailer_unref);
- priv->thumbnailers = NULL;
- }
-
- if (priv->mime_types_map)
- {
- g_hash_table_destroy (priv->mime_types_map);
- priv->mime_types_map = NULL;
- }
-
- if (priv->monitors)
- {
- g_list_free_full (priv->monitors, (GDestroyNotify)g_object_unref);
- priv->monitors = NULL;
- }
-
- g_mutex_clear (&priv->lock);
-
- if (priv->disabled_types)
- {
- g_strfreev (priv->disabled_types);
- priv->disabled_types = NULL;
- }
-
- if (priv->settings)
- {
- g_object_unref (priv->settings);
- priv->settings = NULL;
- }
-
- if (G_OBJECT_CLASS (parent_class)->finalize)
- (* G_OBJECT_CLASS (parent_class)->finalize) (object);
-}
-
/* These should be called with the lock held */
static void
gnome_desktop_thumbnail_factory_register_mime_types (GnomeDesktopThumbnailFactory *factory,
@@ -977,6 +931,49 @@ gnome_desktop_thumbnail_factory_init (GnomeDesktopThumbnailFactory *factory)
}
static void
+gnome_desktop_thumbnail_factory_finalize (GObject *object)
+{
+ GnomeDesktopThumbnailFactory *factory;
+ GnomeDesktopThumbnailFactoryPrivate *priv;
+
+ factory = GNOME_DESKTOP_THUMBNAIL_FACTORY (object);
+
+ priv = factory->priv;
+
+ if (priv->thumbnailers)
+ {
+ g_list_free_full (priv->thumbnailers, (GDestroyNotify)thumbnailer_unref);
+ priv->thumbnailers = NULL;
+ }
+
+ g_clear_pointer (&priv->mime_types_map, g_hash_table_destroy);
+
+ if (priv->monitors)
+ {
+ g_list_free_full (priv->monitors, (GDestroyNotify)g_object_unref);
+ priv->monitors = NULL;
+ }
+
+ g_mutex_clear (&priv->lock);
+
+ g_clear_pointer (&priv->disabled_types, g_strfreev);
+
+ if (priv->settings)
+ {
+ g_signal_handlers_disconnect_by_func (priv->settings,
+ external_thumbnailers_disabled_all_changed_cb,
+ factory);
+ g_signal_handlers_disconnect_by_func (priv->settings,
+ external_thumbnailers_disabled_changed_cb,
+ factory);
+ g_clear_object (&priv->settings);
+ }
+
+ if (G_OBJECT_CLASS (parent_class)->finalize)
+ (* G_OBJECT_CLASS (parent_class)->finalize) (object);
+}
+
+static void
gnome_desktop_thumbnail_factory_class_init (GnomeDesktopThumbnailFactoryClass *class)
{
GObjectClass *gobject_class;