[balsa/gtk3] Possible fix for RedHat bug #1097953 (Geoff Leach)



commit 8a0d77f898d1093b1414e6f3bbd9a0573e14a3e8
Author: Peter Bloomfield <PeterBloomfield bellsouth net>
Date:   Thu Jan 29 09:49:06 2015 -0500

    Possible fix for RedHat bug #1097953 (Geoff Leach)
    
        * src/main-window.c (balsa_window_class_init), (balsa_window_new),
        (bw_close_mailbox_on_timer): use balsa_window_real_close_mbnode
        to close the mailbox instead of directly removing the notebook page.
        * src/message-window.c (destroy_message_window),
        (message_window_new): disconnect mailbox signals more carefully.

 ChangeLog            |   10 ++++++++++
 src/main-window.c    |   14 +++++---------
 src/message-window.c |   10 ++++++++--
 3 files changed, 23 insertions(+), 11 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 1abf95e..90d1169 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2015-01-29  Peter Bloomfield  <pbloomfield bellsouth net>
+
+       Possible fix for RedHat bug #1097953 (Geoff Leach)
+
+       * src/main-window.c (balsa_window_class_init), (balsa_window_new),
+       (bw_close_mailbox_on_timer): use balsa_window_real_close_mbnode
+       to close the mailbox instead of directly removing the notebook page.
+       * src/message-window.c (destroy_message_window),
+       (message_window_new): disconnect mailbox signals more carefully.
+
 2015-01-28  Peter Bloomfield  <pbloomfield bellsouth net>
 
        * balsa.appdata.xml: new appdata file
diff --git a/src/main-window.c b/src/main-window.c
index 2b2402d..0d29fd5 100644
--- a/src/main-window.c
+++ b/src/main-window.c
@@ -121,7 +121,7 @@ static void balsa_window_real_close_mbnode(BalsaWindow *window,
                                           BalsaMailboxNode *mbnode);
 static void balsa_window_destroy(GObject * object);
 
-static gboolean bw_close_mailbox_on_timer(void);
+static gboolean bw_close_mailbox_on_timer(BalsaWindow * window);
 
 static void bw_index_changed_cb(GtkWidget * widget, gpointer data);
 static void bw_idle_replace(BalsaWindow * window, BalsaIndex * bindex);
@@ -231,9 +231,6 @@ balsa_window_class_init(BalsaWindowClass * klass)
 
     /* Signals */
     klass->identities_changed = NULL;
-
-    g_timeout_add_seconds(30, (GSourceFunc) bw_close_mailbox_on_timer, NULL);
-
 }
 
 static gboolean bw_change_connection_status_idle(gpointer data);
@@ -2366,6 +2363,8 @@ balsa_window_new()
     bw_action_set_enabled(window, "get-new-mail", !checking_mail);
 #endif
 
+    g_timeout_add_seconds(30, (GSourceFunc) bw_close_mailbox_on_timer, window);
+
     gtk_widget_show(GTK_WIDGET(window));
     return GTK_WIDGET(window);
 }
@@ -3105,7 +3104,7 @@ balsa_identities_changed(BalsaWindow *bw)
 }
 
 static gboolean
-bw_close_mailbox_on_timer(void)
+bw_close_mailbox_on_timer(BalsaWindow * window)
 {
     time_t current_time;
     GtkWidget *page;
@@ -3116,7 +3115,6 @@ bw_close_mailbox_on_timer(void)
     if (!balsa_app.close_mailbox_auto)
         return TRUE;
 
-    gdk_threads_enter();
     time(&current_time);
 
     c = gtk_notebook_get_current_page(GTK_NOTEBOOK(balsa_app.notebook));
@@ -3136,14 +3134,12 @@ bw_close_mailbox_on_timer(void)
             if (balsa_app.debug)
                 fprintf(stderr, "Closing Page %d unused for %d s\n",
                         i, delta_time);
-            bw_unregister_open_mailbox(index->mailbox_node->mailbox);
-            gtk_notebook_remove_page(GTK_NOTEBOOK(balsa_app.notebook), i);
+            balsa_window_real_close_mbnode(window, index->mailbox_node);
             if (i < c)
                 c--;
             i--;
         }
     }
-    gdk_threads_leave();
     return TRUE;
 }
 
diff --git a/src/message-window.c b/src/message-window.c
index a2e2070..0ca1873 100644
--- a/src/message-window.c
+++ b/src/message-window.c
@@ -47,6 +47,7 @@ struct _MessageWindow {
     GtkWidget *bmessage;
     GtkWidget *toolbar;
 
+    LibBalsaMailbox *mailbox;
     LibBalsaMessage *message;
     BalsaIndex *bindex;
     int headers_shown;
@@ -393,10 +394,13 @@ destroy_message_window(GtkWidget * widget, MessageWindow * mw)
         mw->bindex = NULL;
     }
 
-    if (mw->message && mw->message->mailbox)
-        g_signal_handlers_disconnect_matched(G_OBJECT(mw->message->mailbox),
+    if (mw->mailbox) {
+        g_object_remove_weak_pointer(G_OBJECT(mw->mailbox), (gpointer) &mw->mailbox);
+        g_signal_handlers_disconnect_matched(G_OBJECT(mw->mailbox),
                                              G_SIGNAL_MATCH_DATA, 0, 0,
                                              NULL, NULL, mw);
+        mw->mailbox = NULL;
+    }
 
     if (mw->bmessage)
         g_signal_handlers_disconnect_matched(G_OBJECT(mw->bmessage),
@@ -896,6 +900,8 @@ message_window_new(LibBalsaMailbox * mailbox, guint msgno)
     g_signal_connect_swapped(G_OBJECT(mw->bindex), "index-changed",
                             G_CALLBACK(mw_set_buttons_sensitive), mw);
 
+    mw->mailbox = mailbox;
+    g_object_add_weak_pointer(G_OBJECT(mailbox), (gpointer) &mw->mailbox);
     g_signal_connect(mailbox, "message_expunged",
                      G_CALLBACK(mw_expunged_cb), mw);
 


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