[balsa/gtk3] Filter message in idle callback, not in subthread
- From: Peter Bloomfield <PeterB src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [balsa/gtk3] Filter message in idle callback, not in subthread
- Date: Sun, 10 Jun 2012 01:44:30 +0000 (UTC)
commit 034ab40119ab4ee0fa4e8fa08bbd9f72acf596c8
Author: Peter Bloomfield <PeterBloomfield bellsouth net>
Date: Sat Jun 9 21:41:21 2012 -0400
Filter message in idle callback, not in subthread
* libbalsa/mailbox.c (lbm_msgno_filt_check),
(lbm_msgno_filt_check_idle_cb),
(libbalsa_mailbox_msgno_filt_check): check whether message
matches current view filter in an idle callback instead of in
subthread.
ChangeLog | 8 +++++++
libbalsa/mailbox.c | 53 ++++++++++++++++++++++++++++++++++++++++++++++-----
2 files changed, 55 insertions(+), 6 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 9c0ed71..b629aa3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2012-06-09 Peter Bloomfield
+
+ * libbalsa/mailbox.c (lbm_msgno_filt_check),
+ (lbm_msgno_filt_check_idle_cb),
+ (libbalsa_mailbox_msgno_filt_check): check whether message
+ matches current view filter in an idle callback instead of in
+ subthread.
+
2012-06-08 Peter Bloomfield
* libbalsa/mailbox.c (lbm_msgno_removed_idle_cb),
diff --git a/libbalsa/mailbox.c b/libbalsa/mailbox.c
index d5de5e2..03d4d66 100644
--- a/libbalsa/mailbox.c
+++ b/libbalsa/mailbox.c
@@ -1703,15 +1703,13 @@ libbalsa_mailbox_msgno_filt_out(LibBalsaMailbox * mailbox, guint seqno)
* messages;
* - if it isn't in the view and it matches the condition, filter it in.
*/
-void
-libbalsa_mailbox_msgno_filt_check(LibBalsaMailbox * mailbox, guint seqno,
- LibBalsaMailboxSearchIter * search_iter,
- gboolean hold_selected)
+static void
+lbm_msgno_filt_check(LibBalsaMailbox * mailbox, guint seqno,
+ LibBalsaMailboxSearchIter * search_iter,
+ gboolean hold_selected)
{
gboolean match;
- g_return_if_fail(LIBBALSA_IS_MAILBOX(mailbox));
-
gdk_threads_enter();
if (!mailbox->msg_tree) {
@@ -1749,6 +1747,49 @@ libbalsa_mailbox_msgno_filt_check(LibBalsaMailbox * mailbox, guint seqno,
gdk_threads_leave();
}
+#ifdef BALSA_USE_THREADS
+typedef struct {
+ LibBalsaMailbox *mailbox;
+ guint seqno;
+ LibBalsaMailboxSearchIter *search_iter;
+ gboolean hold_selected;
+} LbmMsgnoFiltCheckInfo;
+
+static gboolean
+lbm_msgno_filt_check_idle_cb(LbmMsgnoFiltCheckInfo * info)
+{
+ lbm_msgno_filt_check(info->mailbox, info->seqno, info->search_iter,
+ info->hold_selected);
+ g_object_unref(info->mailbox);
+ g_slice_free(LbmMsgnoFiltCheckInfo, info);
+ return FALSE;
+}
+#endif /* BALSA_USE_THREADS */
+
+void
+libbalsa_mailbox_msgno_filt_check(LibBalsaMailbox * mailbox, guint seqno,
+ LibBalsaMailboxSearchIter * search_iter,
+ gboolean hold_selected)
+{
+ g_return_if_fail(LIBBALSA_IS_MAILBOX(mailbox));
+
+#ifdef BALSA_USE_THREADS
+ if (libbalsa_am_i_subthread()) {
+ LbmMsgnoFiltCheckInfo *info;
+
+ info = g_slice_new(LbmMsgnoFiltCheckInfo);
+ info->mailbox = g_object_ref(mailbox);
+ info->seqno = seqno;
+ info->search_iter = search_iter;
+ info->hold_selected = hold_selected;
+ g_idle_add((GSourceFunc) lbm_msgno_filt_check_idle_cb, info);
+ } else
+ lbm_msgno_filt_check(mailbox, seqno, search_iter, hold_selected);
+#else /* BALSA_USE_THREADS */
+ lbm_msgno_filt_check(mailbox, seqno, search_iter, hold_selected);
+#endif /* BALSA_USE_THREADS */
+}
+
/* Search iters */
LibBalsaMailboxSearchIter *
libbalsa_mailbox_search_iter_new(LibBalsaCondition * condition)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]