[balsa] mailbox: when closing a mailbox, remove source



commit 29b92853ac2546983d14048eedb250da8f8d645e
Author: Peter Bloomfield <PeterBloomfield bellsouth net>
Date:   Thu Jan 9 12:53:46 2020 -0500

    mailbox: when closing a mailbox, remove source
    
    When closing a mailbox, remove the source of any
    pending run-filters-on-reception idle callback.
    
    * libbalsa/mailbox.c (libbalsa_mailbox_close): remove the source, if any;
      (libbalsa_mailbox_run_filters_on_reception): check that no callback is pending.

 ChangeLog          | 10 ++++++++++
 libbalsa/mailbox.c | 11 +++++++++--
 2 files changed, 19 insertions(+), 2 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index b61ce6f11..84a917de3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2020-01-09  Peter Bloomfield  <pbloomfield bellsouth net>
+
+       mailbox: when closing a mailbox, remove the source of any
+       pending run-filters-on-reception idle callback.
+
+       * libbalsa/mailbox.c (libbalsa_mailbox_close): remove the
+       source, if any;
+       (libbalsa_mailbox_run_filters_on_reception): check that no
+       callback is pending.
+
 2020-01-09  Peter Bloomfield  <pbloomfield bellsouth net>
 
        balsa-index: minor cleanup
diff --git a/libbalsa/mailbox.c b/libbalsa/mailbox.c
index 418e4049c..d05775b1e 100644
--- a/libbalsa/mailbox.c
+++ b/libbalsa/mailbox.c
@@ -653,6 +653,11 @@ libbalsa_mailbox_close(LibBalsaMailbox * mailbox, gboolean expunge)
        priv->state = LB_MAILBOX_STATE_CLOSED;
         priv->messages_loaded = FALSE;
         priv->messages_threaded = FALSE;
+
+        if (priv->run_filters_idle_id != 0) {
+            g_source_remove(priv->run_filters_idle_id);
+            priv->run_filters_idle_id = 0;
+        }
     }
 
     libbalsa_unlock_mailbox(mailbox);
@@ -940,8 +945,10 @@ libbalsa_mailbox_run_filters_on_reception(LibBalsaMailbox * mailbox)
 
     g_return_if_fail(LIBBALSA_IS_MAILBOX(mailbox));
 
-    priv->run_filters_idle_id =
-        g_idle_add((GSourceFunc) lbm_run_filters_on_reception_idle_cb, mailbox);
+    if (priv->run_filters_idle_id == 0) {
+        priv->run_filters_idle_id =
+            g_idle_add((GSourceFunc) lbm_run_filters_on_reception_idle_cb, mailbox);
+    }
 }
 
 void


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