[balsa] Fix a mailbox-threading bug.



commit 4e0c823d8c5e651017ec92742dffca5d72a38338
Author: Peter Bloomfield <PeterBloomfield bellsouth net>
Date:   Sat Nov 9 16:32:10 2019 -0500

    Fix a mailbox-threading bug.
    
    When adding a new mailbox, we used the UI to set its threading type;
    unfortunately, the UI sets the threading on the currently shown mailbox
    instead. Spotted when the new local mailbox should have threading enabled,
    and the current mailbox is IMAP and does not support threading.
    
    * libbalsa/mailbox.c (libbalsa_mailbox_set_threading_type): call
      libbalsa_mailbox_set_threading() if the mailbox is non-NULL,
      instead of making the caller do it;
    * src/balsa-index.c (balsa_index_set_thread_messages): do not call
      libbalsa_mailbox_set_threading();
    * src/mailbox-conf.c: drop BalsaMailboxConfView:mailbox--no one
      is now using it;
      (mailbox_conf_view_new_full): no one is now using
      BalsaMailboxConfView:mailbox;
      (mailbox_conf_view_check): set the threading type directly on
      the mailbox, instead of using the UI;
    * src/main-window.c: drop balsa_window_set_thread_messages, as
      it is no longer needed;
      (bw_enable_mailbox_menus): include the guts of
      balsa_window_set_thread_messages in-line;
    * src/main-window.h: drop balsa_window_set_thread_messages.

 ChangeLog          | 27 +++++++++++++++++++++++++++
 libbalsa/mailbox.c |  4 +++-
 src/balsa-index.c  |  1 -
 src/mailbox-conf.c | 14 ++++++++------
 src/main-window.c  | 20 ++++----------------
 src/main-window.h  |  1 -
 6 files changed, 42 insertions(+), 25 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index c50deca4b..88a1e4342 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,30 @@
+2019-11-09  Peter Bloomfield  <pbloomfield bellsouth net>
+
+       Fix a mailbox-threading bug.
+
+       When adding a new mailbox, we used the UI to set its threading
+       type; unfortunately, the UI sets the threading on the currently
+       shown mailbox instead. Spotted when the new local mailbox should
+       have threading enabled, and the current mailbox is IMAP and
+       does not support threading.
+
+       * libbalsa/mailbox.c (libbalsa_mailbox_set_threading_type): call
+       libbalsa_mailbox_set_threading() if the mailbox is non-NULL,
+       instead of making the caller do it;
+       * src/balsa-index.c (balsa_index_set_thread_messages): do not call
+       libbalsa_mailbox_set_threading();
+       * src/mailbox-conf.c: drop BalsaMailboxConfView:mailbox--no one
+       is now using it;
+       (mailbox_conf_view_new_full): no one is now using
+       BalsaMailboxConfView:mailbox;
+       (mailbox_conf_view_check): set the threading type directly on
+       the mailbox, instead of using the UI;
+       * src/main-window.c: drop balsa_window_set_thread_messages, as
+       it is no longer needed;
+       (bw_enable_mailbox_menus): include the guts of
+       balsa_window_set_thread_messages in-line;
+       * src/main-window.h: drop balsa_window_set_thread_messages.
+
 2019-10-19  Pawel Salek  <pawsa0 gmail com>
 
        * NEWS, configure.ac, meson.build: release balsa-2.5.9
diff --git a/libbalsa/mailbox.c b/libbalsa/mailbox.c
index deaad4bed..cd21c09d2 100644
--- a/libbalsa/mailbox.c
+++ b/libbalsa/mailbox.c
@@ -2423,8 +2423,10 @@ libbalsa_mailbox_set_threading_type(LibBalsaMailbox * mailbox,
 
     if (view->threading_type != threading_type) {
        view->threading_type = threading_type;
-       if (mailbox)
+       if (mailbox != NULL) {
            view->in_sync = 0;
+            libbalsa_mailbox_set_threading(mailbox);
+        }
     }
 }
 
diff --git a/src/balsa-index.c b/src/balsa-index.c
index 292e4ae7e..1bc1588c5 100644
--- a/src/balsa-index.c
+++ b/src/balsa-index.c
@@ -2086,7 +2086,6 @@ balsa_index_set_thread_messages(BalsaIndex * index,
         return;
 
     libbalsa_mailbox_set_threading_type(mailbox, threading_type);
-    libbalsa_mailbox_set_threading(mailbox);
     balsa_index_update_tree(index, balsa_app.expand_tree);
 }
 
diff --git a/src/mailbox-conf.c b/src/mailbox-conf.c
index 3f0eac478..57462cf63 100644
--- a/src/mailbox-conf.c
+++ b/src/mailbox-conf.c
@@ -69,7 +69,6 @@ struct _BalsaMailboxConfView {
     GtkWidget *chk_crypt;
     GtkWidget *thread_messages;
     GtkWidget *subject_gather;
-    LibBalsaMailbox *mailbox;
 };
 
 typedef struct _MailboxConfWindow MailboxConfWindow;
@@ -878,7 +877,6 @@ mailbox_conf_view_new_full(LibBalsaMailbox * mailbox,
 
     view_info = g_new(BalsaMailboxConfView, 1);
     g_object_weak_ref(G_OBJECT(window), (GWeakNotify) g_free, view_info);
-    view_info->mailbox = mailbox;
 
     label = libbalsa_create_grid_label(_("_Identity:"), grid, row);
     if (size_group)
@@ -1007,6 +1005,7 @@ mailbox_conf_view_check(BalsaMailboxConfView * view_info,
     GtkComboBox *combo_box;
     GtkTreeIter iter;
     gint active;
+    LibBalsaMailboxThreadingType threading_type;
 
     g_return_if_fail(LIBBALSA_IS_MAILBOX(mailbox));
     if (view_info == NULL)     /* POP3 mailboxes do not have view_info */
@@ -1051,14 +1050,17 @@ mailbox_conf_view_check(BalsaMailboxConfView * view_info,
 
     active = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON
                                           (view_info->subject_gather));
-    libbalsa_mailbox_set_subject_gather(view_info->mailbox, active);
+    libbalsa_mailbox_set_subject_gather(mailbox, active);
+    threading_type = active ? LB_MAILBOX_THREADING_JWZ : LB_MAILBOX_THREADING_SIMPLE;
 
     active = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON
                                           (view_info->thread_messages));
-    balsa_window_set_thread_messages(balsa_app.main_window, active);
+    /* Set the threading type directly, not through the UI: */
+    libbalsa_mailbox_set_threading_type(mailbox,
+                                        active ? threading_type : LB_MAILBOX_THREADING_FLAT);
 
-    if (libbalsa_mailbox_set_crypto_mode(mailbox,
-                                        gtk_combo_box_get_active(GTK_COMBO_BOX(view_info->chk_crypt))))
+    active = gtk_combo_box_get_active(GTK_COMBO_BOX(view_info->chk_crypt));
+    if (libbalsa_mailbox_set_crypto_mode(mailbox, active))
        changed = TRUE;
 
     if (!changed || !libbalsa_mailbox_get_open(mailbox))
diff --git a/src/main-window.c b/src/main-window.c
index 3ffa3cc12..2a249d0e4 100644
--- a/src/main-window.c
+++ b/src/main-window.c
@@ -2494,9 +2494,10 @@ bw_enable_mailbox_menus(BalsaWindow * window, BalsaIndex * index)
                           libbalsa_mailbox_can_move_duplicates(mailbox));
 
     if (mailbox != NULL) {
-        balsa_window_set_thread_messages(window,
-                                         libbalsa_mailbox_get_threading_type(mailbox)
-                                         != LB_MAILBOX_THREADING_FLAT);
+        bw_action_set_boolean(window, "threading",
+                              libbalsa_mailbox_get_threading_type(mailbox) !=
+                              LB_MAILBOX_THREADING_FLAT);
+        bw_enable_expand_collapse(window, mailbox);
        bw_set_filter_menu(window, libbalsa_mailbox_get_filter(mailbox));
     }
 
@@ -2688,19 +2689,6 @@ bw_enable_part_menu_items(BalsaWindow * window)
                           balsa_message_has_previous_part(msg));
 }
 
-void
-balsa_window_set_thread_messages(BalsaWindow * window, gboolean thread_messages)
-{
-    GtkWidget *index;
-    LibBalsaMailbox *mailbox;
-
-    bw_action_set_boolean(window, "threading", thread_messages);
-
-    if ((index = balsa_window_find_current_index(window)) != NULL
-        && (mailbox = balsa_index_get_mailbox(BALSA_INDEX(index))) != NULL)
-        bw_enable_expand_collapse(window, mailbox);
-}
-
 static void
 bw_set_filter_menu(BalsaWindow * window, int mask)
 {
diff --git a/src/main-window.h b/src/main-window.h
index e6a9ed38a..ed616c658 100644
--- a/src/main-window.h
+++ b/src/main-window.h
@@ -110,7 +110,6 @@ void balsa_window_decrease_activity(BalsaWindow * window,
                                     const gchar * message);
 void balsa_window_set_statusbar(BalsaWindow     * window,
                                 LibBalsaMailbox * mailbox);
-void balsa_window_set_thread_messages(BalsaWindow * window, gboolean thread_messages);
 
 /*
  * Getter


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