From: David Bremner <david@tethera.net>
To: notmuch@notmuchmail.org
Cc: David Bremner <david@tethera.net>
Subject: [PATCH 4/5] lib/thread: replace use of deprecated notmuch_message_get_flag
Date: Sat, 11 Jul 2020 15:30:07 -0300 [thread overview]
Message-ID: <20200711183008.1593624-5-david@tethera.net> (raw)
In-Reply-To: <20200711183008.1593624-1-david@tethera.net>
This adds one more reason why _notmuch_thread_create might return
NULL, but those were not previously enumerated, so no promises are
broken.
---
lib/thread.cc | 16 ++++++++++++----
1 file changed, 12 insertions(+), 4 deletions(-)
diff --git a/lib/thread.cc b/lib/thread.cc
index 6073e45c..17346008 100644
--- a/lib/thread.cc
+++ b/lib/thread.cc
@@ -351,14 +351,16 @@ _thread_set_subject_from_message (notmuch_thread_t *thread,
/* Add a message to this thread which is known to match the original
* search specification. The 'sort' parameter controls whether the
* oldest or newest matching subject is applied to the thread as a
- * whole. */
-static void
+ * whole. Returns 0 on success.
+ */
+static int
_thread_add_matched_message (notmuch_thread_t *thread,
notmuch_message_t *message,
notmuch_sort_t sort)
{
time_t date;
notmuch_message_t *hashed_message;
+ notmuch_bool_t is_set;
date = notmuch_message_get_date (message);
@@ -375,7 +377,9 @@ _thread_add_matched_message (notmuch_thread_t *thread,
_thread_set_subject_from_message (thread, message);
}
- if (! notmuch_message_get_flag (message, NOTMUCH_MESSAGE_FLAG_EXCLUDED))
+ if (notmuch_message_get_flag_st (message, NOTMUCH_MESSAGE_FLAG_EXCLUDED, &is_set))
+ return -1;
+ if (! is_set)
thread->matched_messages++;
if (g_hash_table_lookup_extended (thread->message_hash,
@@ -386,6 +390,7 @@ _thread_add_matched_message (notmuch_thread_t *thread,
}
_thread_add_matched_author (thread, _notmuch_message_get_author (hashed_message));
+ return 0;
}
static bool
@@ -625,7 +630,10 @@ _notmuch_thread_create (void *ctx,
if ( _notmuch_doc_id_set_contains (match_set, doc_id)) {
_notmuch_doc_id_set_remove (match_set, doc_id);
- _thread_add_matched_message (thread, message, sort);
+ if (_thread_add_matched_message (thread, message, sort)) {
+ thread = NULL;
+ goto DONE;
+ }
}
_notmuch_message_close (message);
--
2.27.0
next prev parent reply other threads:[~2020-07-11 18:30 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-11 18:30 fix deprecation warnings for notmuch_message_get_flag David Bremner
2020-07-11 18:30 ` [PATCH 1/5] cli/search: replace deprecated notmuch_message_get_flag David Bremner
2020-07-11 18:30 ` [PATCH 2/5] cli/show: " David Bremner
2020-07-11 18:30 ` [PATCH 3/5] lib/add-message: drop use of " David Bremner
2020-07-11 18:30 ` David Bremner [this message]
2020-07-11 18:30 ` [PATCH 5/5] bindings/ruby: replacy " David Bremner
2020-07-13 23:51 ` [PATCH] cli/new: replace newly deprecated n_m_has_maildir_flag David Bremner
2020-07-20 12:14 ` David Bremner
2020-07-18 14:31 ` fix deprecation warnings for notmuch_message_get_flag David Bremner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://notmuchmail.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200711183008.1593624-5-david@tethera.net \
--to=david@tethera.net \
--cc=notmuch@notmuchmail.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://yhetil.org/notmuch.git/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).