[glib/wip/hadess/gnetworkmonitor-nm-fixups: 2/5] gnetworkmonitornm: Disconnect g-signal from proxy
- From: Bastien Nocera <hadess src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib/wip/hadess/gnetworkmonitor-nm-fixups: 2/5] gnetworkmonitornm: Disconnect g-signal from proxy
- Date: Mon, 29 Jul 2019 15:28:29 +0000 (UTC)
commit 7d3ecce346c8c4a55fbf7f5c6f9c2ec954dea6fb
Author: Bastien Nocera <hadess hadess net>
Date: Mon Jul 29 17:25:21 2019 +0200
gnetworkmonitornm: Disconnect g-signal from proxy
So that we're sure never to receive a signal if something is keeping the
proxy alive.
gio/gnetworkmonitornm.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
---
diff --git a/gio/gnetworkmonitornm.c b/gio/gnetworkmonitornm.c
index 9013fd49c..52073fac9 100644
--- a/gio/gnetworkmonitornm.c
+++ b/gio/gnetworkmonitornm.c
@@ -68,6 +68,7 @@ typedef enum {
struct _GNetworkMonitorNMPrivate
{
GDBusProxy *proxy;
+ guint signal_id;
GNetworkConnectivity connectivity;
gboolean network_available;
@@ -360,8 +361,8 @@ g_network_monitor_nm_initable_init (GInitable *initable,
return FALSE;
}
- g_signal_connect (G_OBJECT (proxy), "g-signal",
- G_CALLBACK (proxy_signal_cb), nm);
+ nm->priv->signal_id = g_signal_connect (G_OBJECT (proxy), "g-signal",
+ G_CALLBACK (proxy_signal_cb), nm);
nm->priv->proxy = proxy;
sync_properties (nm, FALSE);
@@ -373,6 +374,13 @@ g_network_monitor_nm_finalize (GObject *object)
{
GNetworkMonitorNM *nm = G_NETWORK_MONITOR_NM (object);
+ if (nm->priv->proxy != NULL &&
+ nm->priv->signal_id != 0)
+ {
+ g_signal_handler_disconnect (nm->priv->proxy,
+ nm->priv->signal_id);
+ nm->priv->signal_id = 0;
+ }
g_clear_object (&nm->priv->proxy);
G_OBJECT_CLASS (g_network_monitor_nm_parent_class)->finalize (object);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]