From 7e0397def3b6683ef8a898def76d0be4080c65d1 Mon Sep 17 00:00:00 2001 From: Beniamino Galvani Date: Mon, 23 Mar 2015 21:44:24 +0100 Subject: settings: reference inotify helper singleton To avoid errors during destruction, singletons should keep a reference to other singletons they subscribe to. --- src/settings/nm-settings.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/settings/nm-settings.c b/src/settings/nm-settings.c index a043e9b225..b9b6907916 100644 --- a/src/settings/nm-settings.c +++ b/src/settings/nm-settings.c @@ -177,6 +177,8 @@ typedef struct { GFileMonitor *dhcp_monitor; guint hostname_monitor_id; guint dhcp_monitor_id; + + NMInotifyHelper *ih; gulong ih_event_id; int sc_network_wd; } NMSettingsPrivate; @@ -2111,8 +2113,6 @@ setup_hostname_file_monitors (NMSettings *self) #endif if (sysconfig_hostname_read) { - NMInotifyHelper *ih; - /* We watch SC_NETWORK_FILE via NMInotifyHelper (which doesn't track file * creation but *does* track modifications made via other hard links), * since we expect it to always exist. But we watch HOSTNAME_FILE via @@ -2120,10 +2120,11 @@ setup_hostname_file_monitors (NMSettings *self) * might not exist, but is unlikely to have hard links. bgo 532815 is the * bug for being able to just use GFileMonitor for both. */ - ih = nm_inotify_helper_get (); - priv->ih_event_id = g_signal_connect (ih, "event", + priv->ih = g_object_ref (nm_inotify_helper_get ()); + priv->ih_event_id = g_signal_connect (priv->ih, "event", G_CALLBACK (sc_network_changed_cb), self); - priv->sc_network_wd = nm_inotify_helper_add_watch (ih, HOSTNAME_FILE_SYSCONFIG); + priv->sc_network_wd = nm_inotify_helper_add_watch (priv->ih, + HOSTNAME_FILE_SYSCONFIG); } } @@ -2211,7 +2212,6 @@ dispose (GObject *object) { NMSettings *self = NM_SETTINGS (object); NMSettingsPrivate *priv = NM_SETTINGS_GET_PRIVATE (self); - NMInotifyHelper *ih; g_slist_free_full (priv->auths, (GDestroyNotify) nm_auth_chain_unref); priv->auths = NULL; @@ -2243,14 +2243,14 @@ dispose (GObject *object) g_clear_object (&priv->dhcp_monitor); } - if (priv->ih_event_id) { - ih = nm_inotify_helper_get (); - - g_signal_handler_disconnect (ih, priv->ih_event_id); - priv->ih_event_id = 0; - - if (priv->sc_network_wd >= 0) - nm_inotify_helper_remove_watch (ih, priv->sc_network_wd); + if (priv->ih) { + if (priv->ih_event_id) { + g_signal_handler_disconnect (priv->ih, priv->ih_event_id); + priv->ih_event_id = 0; + if (priv->sc_network_wd >= 0) + nm_inotify_helper_remove_watch (priv->ih, priv->sc_network_wd); + } + g_clear_object (&priv->ih); } g_free (priv->hostname); -- cgit v1.2.1