From 772cf7f8bc20122213bee2fbbf0c46885b4db83b Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Sun, 24 Jan 2016 12:07:25 -0500 Subject: 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 origin commit: https://gitlab.gnome.org/GNOME/gnome-desktop/commit/f32c389 --- libmate-desktop/mate-desktop-thumbnail.c | 89 +++++++++++++++----------------- 1 file changed, 43 insertions(+), 46 deletions(-) (limited to 'libmate-desktop/mate-desktop-thumbnail.c') diff --git a/libmate-desktop/mate-desktop-thumbnail.c b/libmate-desktop/mate-desktop-thumbnail.c index 54225d0..6678f74 100644 --- a/libmate-desktop/mate-desktop-thumbnail.c +++ b/libmate-desktop/mate-desktop-thumbnail.c @@ -467,52 +467,6 @@ _gdk_pixbuf_new_from_uri_at_scale (const char *uri, return pixbuf; } -static void -mate_desktop_thumbnail_factory_finalize (GObject *object) -{ - MateDesktopThumbnailFactory *factory; - MateDesktopThumbnailFactoryPrivate *priv; - - factory = MATE_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 mate_desktop_thumbnail_factory_register_mime_types (MateDesktopThumbnailFactory *factory, @@ -865,6 +819,49 @@ mate_desktop_thumbnail_factory_init (MateDesktopThumbnailFactory *factory) mate_desktop_thumbnail_factory_load_thumbnailers (factory); } +static void +mate_desktop_thumbnail_factory_finalize (GObject *object) +{ + MateDesktopThumbnailFactory *factory; + MateDesktopThumbnailFactoryPrivate *priv; + + factory = MATE_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 mate_desktop_thumbnail_factory_class_init (MateDesktopThumbnailFactoryClass *class) { -- cgit v1.2.1