[balsa/gtk3] Reopen mailboxes after rescanning



commit 0929a9ce164168c7b43a82202c5034ae889afe3f
Author: Peter Bloomfield <PeterBloomfield bellsouth net>
Date:   Sun Mar 17 11:59:12 2013 -0400

    Reopen mailboxes after rescanning
    
        * src/mailbox-node.c (imap_dir_cb): do not unref mbnode;
        (imap_scan_create_mbnode): do not ref mbnode; protect view
        during rescanning;
        (balsa_mailbox_node_rescan): reopen mailboxes after scanning.

 ChangeLog          |    9 +++++++++
 src/mailbox-node.c |   14 +++++++++++---
 2 files changed, 20 insertions(+), 3 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 887c9aa..806a381 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,14 @@
 2013-03-17  Peter Bloomfield
 
+       Reopen mailboxes after rescanning
+
+       * src/mailbox-node.c (imap_dir_cb): do not unref mbnode;
+       (imap_scan_create_mbnode): do not ref mbnode; protect view
+       during rescanning;
+       (balsa_mailbox_node_rescan): reopen mailboxes after scanning.
+
+2013-03-17  Peter Bloomfield
+
        * libbalsa/libbalsa-conf.c (libbalsa_conf_sync),
        (libbalsa_conf_sync_idle_cb): remove source in public method.
 
diff --git a/src/mailbox-node.c b/src/mailbox-node.c
index 4e9f3ce..da3c93e 100644
--- a/src/mailbox-node.c
+++ b/src/mailbox-node.c
@@ -537,8 +537,6 @@ imap_dir_cb(BalsaMailboxNode* mb)
            balsa_mblist_mailbox_node_redraw(n);
         if(item->marked)
             libbalsa_mailbox_set_unread_messages_flag(n->mailbox, TRUE);
-       g_object_unref(n);
-        
     }
     imap_scan_destroy_tree(&imap_tree);
 
@@ -775,6 +773,9 @@ balsa_mailbox_node_rescan(BalsaMailboxNode * mn)
     }
     mn->scanned = FALSE;
     balsa_mailbox_node_append_subtree(mn);
+
+    /* Reopen mailboxes */
+    open_mailboxes_idle_cb(NULL);
 }
 
 void
@@ -1301,6 +1302,7 @@ imap_scan_create_mbnode(BalsaMailboxNode * root, imap_scan_item * isi,
     mbnode = balsa_find_url(url);
     if (mbnode) {
        /* A mailbox with this url is already in the tree... */
+       LibBalsaMailboxView *view;
        BalsaMailboxNode *special =
            remove_special_mailbox_by_url(url, &isi->special);
        if (special) {
@@ -1310,7 +1312,14 @@ imap_scan_create_mbnode(BalsaMailboxNode * root, imap_scan_item * isi,
        } else {
             balsa_mblist_mailbox_node_remove(mbnode);
         }
+        /* Unreffing mbnode may finalize it, which would push the
+         * mailbox view to the config; to save the open state, we
+         * retrieve the view from the config, and restore it after
+         * unreffing. */
+        view = config_load_mailbox_view(url);
        g_object_unref(mbnode);
+        config_save_mailbox_view(url, view);
+        libbalsa_mailbox_view_free(view);
     }
     g_free(url);
 
@@ -1335,7 +1344,6 @@ imap_scan_create_mbnode(BalsaMailboxNode * root, imap_scan_item * isi,
     mbnode->subscribed = parent->subscribed;
     mbnode->scanned = isi->scanned;
 
-    g_object_ref(mbnode);
     balsa_mblist_mailbox_node_append(mbnode->parent, mbnode);
     g_object_unref(parent);
     


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