balsa r8021 - in trunk: . src



Author: PeterB
Date: Wed Dec 24 18:28:32 2008
New Revision: 8021
URL: http://svn.gnome.org/viewvc/balsa?rev=8021&view=rev

Log:
do not crash on exit

Modified:
   trunk/ChangeLog
   trunk/src/balsa-app.c
   trunk/src/main-window.c
   trunk/src/save-restore.c

Modified: trunk/src/balsa-app.c
==============================================================================
--- trunk/src/balsa-app.c	(original)
+++ trunk/src/balsa-app.c	Wed Dec 24 18:28:32 2008
@@ -451,9 +451,6 @@
 balsa_app_destroy(void)
 {
     config_views_save();
-    if (balsa_app.empty_trash_on_exit)
-	empty_trash(balsa_app.main_window);
-
     config_save();
 
     g_list_foreach(balsa_app.address_book_list, (GFunc)g_object_unref, NULL);

Modified: trunk/src/main-window.c
==============================================================================
--- trunk/src/main-window.c	(original)
+++ trunk/src/main-window.c	Wed Dec 24 18:28:32 2008
@@ -4642,22 +4642,28 @@
     LibBalsaMailbox *mailbox;
     gchar *title;
 
-    page = gtk_notebook_get_nth_page(GTK_NOTEBOOK(notebook), page_num);
-    index = BALSA_INDEX(gtk_bin_get_child(GTK_BIN(page)));
-
-    mailbox = index->mailbox_node->mailbox;
     if (window->current_index) {
 	g_object_remove_weak_pointer(G_OBJECT(window->current_index),
 				     (gpointer) &window->current_index);
 	/* Note when this mailbox was hidden, for use in auto-closing. */
 	time(&BALSA_INDEX(window->current_index)->mailbox_node->last_use);
+        window->current_index = NULL;
     }
+
+    if (!balsa_app.mblist_tree_store)
+        /* Quitt'n time! */
+        return;
+
+    page = gtk_notebook_get_nth_page(GTK_NOTEBOOK(notebook), page_num);
+    index = BALSA_INDEX(gtk_bin_get_child(GTK_BIN(page)));
+
     window->current_index = GTK_WIDGET(index);
     g_object_add_weak_pointer(G_OBJECT(window->current_index),
 			      (gpointer) &window->current_index);
     /* Note when this mailbox was exposed, for use in auto-expunge. */
     time(&BALSA_INDEX(window->current_index)->mailbox_node->last_use);
 
+    mailbox = index->mailbox_node->mailbox;
     if (mailbox->name) {
         if (mailbox->readonly) {
             title =

Modified: trunk/src/save-restore.c
==============================================================================
--- trunk/src/save-restore.c	(original)
+++ trunk/src/save-restore.c	Wed Dec 24 18:28:32 2008
@@ -389,6 +389,18 @@
 
 /* Initialize the specified mailbox, creating the internal data
    structures which represent the mailbox. */
+static void
+sr_special_notify(gpointer data, GObject * mailbox)
+{
+    LibBalsaMailbox **special = data;
+
+    if (special == &balsa_app.trash && !balsa_app.mblist_tree_store
+        && balsa_app.empty_trash_on_exit)
+        empty_trash(balsa_app.main_window);
+
+    *special = NULL;
+}
+
 static gint
 config_mailbox_init(const gchar * prefix)
 {
@@ -441,7 +453,8 @@
 	     * and outbox, and view->subscribe gets set correctly for
              * trashbox. */
 	    *special = mailbox;
-	    g_object_add_weak_pointer(G_OBJECT(mailbox), (gpointer) special);
+            g_object_weak_ref(G_OBJECT(mailbox),
+                              (GWeakNotify) sr_special_notify, special);
 	}
 
         balsa_mblist_mailbox_node_append(NULL, mbnode);



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