[balsa] main-window: Really disconnect signal



commit 547eb5aa36b845934826bda2225290c022bec2c5
Author: Peter Bloomfield <PeterBloomfield bellsouth net>
Date:   Thu Jan 9 14:44:19 2020 -0500

    main-window: Really disconnect signal
    
    Really disconnect from a network monitor signal
    
    * src/main-window.c (balsa_window_init): store the network
      monitor's "network-changed" signal handler id;
      (balsa_window_destroy): use it to disconnect the handler.

 ChangeLog         |  8 ++++++++
 src/main-window.c | 16 +++++++++-------
 2 files changed, 17 insertions(+), 7 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 84a917de3..64848a2fb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2020-01-09  Peter Bloomfield  <pbloomfield bellsouth net>
+
+       main-window: Really disconnect from a network monitor signal
+
+       * src/main-window.c (balsa_window_init): store the network
+       monitor's "network-changed" signal handler id;
+       (balsa_window_destroy): use it to disconnect the handler.
+
 2020-01-09  Peter Bloomfield  <pbloomfield bellsouth net>
 
        mailbox: when closing a mailbox, remove the source of any
diff --git a/src/main-window.c b/src/main-window.c
index ad004e6b6..026c1a587 100644
--- a/src/main-window.c
+++ b/src/main-window.c
@@ -224,6 +224,7 @@ struct _BalsaWindowPrivate {
     gboolean network_available;
     time_t last_check_time;
     guint network_changed_source_id;
+    gulong network_changed_handler_id;
 };
 
 G_DEFINE_TYPE_WITH_PRIVATE(BalsaWindow, balsa_window, GTK_TYPE_APPLICATION_WINDOW)
@@ -302,8 +303,9 @@ balsa_window_init(BalsaWindow * window)
     priv->network_available =
         g_network_monitor_get_network_available(monitor);
     print_network_status(priv->network_available);
-    g_signal_connect(monitor, "network-changed",
-                     G_CALLBACK(bw_network_changed_cb), window);
+    priv->network_changed_handler_id =
+        g_signal_connect(monitor, "network-changed",
+                         G_CALLBACK(bw_network_changed_cb), window);
     priv->last_check_time = 0;
 }
 
@@ -3178,7 +3180,6 @@ balsa_window_destroy(GObject * object)
 {
     BalsaWindow *window = BALSA_WINDOW(object);
     BalsaWindowPrivate *priv = balsa_window_get_instance_private(window);
-    GNetworkMonitor *monitor;
 
     bw_idle_remove(window);
     /* The preview window seems to get finalized without notification;
@@ -3190,10 +3191,11 @@ balsa_window_destroy(GObject * object)
         priv->network_changed_source_id = 0;
     }
 
-    monitor = g_network_monitor_get_default();
-    g_signal_handlers_disconnect_by_func(monitor,
-                                         G_CALLBACK(bw_network_changed_cb),
-                                         NULL);
+    if (priv->network_changed_handler_id != 0) {
+        GNetworkMonitor *monitor = g_network_monitor_get_default();
+        g_signal_handler_disconnect(monitor, priv->network_changed_handler_id);
+        priv->network_changed_handler_id = 0;
+    }
 
     balsa_app.in_destruction = TRUE;
     G_OBJECT_CLASS(balsa_window_parent_class)->dispose(object);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]