diff options
author | Matthias Clasen <[email protected]> | 2016-01-24 12:07:25 -0500 |
---|---|---|
committer | monsta <[email protected]> | 2020-02-16 14:02:10 +0300 |
commit | 4b5002f327375c7f20f80be8174c64aae653d63a (patch) | |
tree | b3082f97b75c30e7693b0286be67b1e377f048d7 | |
parent | 3d795f067156c1ab50ccfa8a29b88e0c6c88e011 (diff) | |
download | mate-desktop-4b5002f327375c7f20f80be8174c64aae653d63a.tar.bz2 mate-desktop-4b5002f327375c7f20f80be8174c64aae653d63a.tar.xz |
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
-rw-r--r-- | libmate-desktop/mate-desktop-thumbnail.c | 89 |
1 files changed, 43 insertions, 46 deletions
diff --git a/libmate-desktop/mate-desktop-thumbnail.c b/libmate-desktop/mate-desktop-thumbnail.c index 26b8c17..b1c8001 100644 --- a/libmate-desktop/mate-desktop-thumbnail.c +++ b/libmate-desktop/mate-desktop-thumbnail.c @@ -462,52 +462,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, @@ -806,6 +760,49 @@ mate_desktop_thumbnail_factory_init (MateDesktopThumbnailFactory *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) { GObjectClass *gobject_class; |