summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Clasen <[email protected]>2016-01-24 12:07:25 -0500
committerraveit65 <[email protected]>2020-01-09 00:06:04 +0100
commit772cf7f8bc20122213bee2fbbf0c46885b4db83b (patch)
tree8980d5883288978ebccfce849e780d7307f1ccda
parentb1a710ce7c6048856e5cdd4d5b87bfb2e66e5880 (diff)
downloadmate-desktop-772cf7f8bc20122213bee2fbbf0c46885b4db83b.tar.bz2
mate-desktop-772cf7f8bc20122213bee2fbbf0c46885b4db83b.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.c89
1 files changed, 43 insertions, 46 deletions
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,
@@ -866,6 +820,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;