]> git.notmuchmail.org Git - notmuch/commitdiff
lib/thread: replace use of deprecated notmuch_message_get_flag
authorDavid Bremner <david@tethera.net>
Sat, 11 Jul 2020 18:30:07 +0000 (15:30 -0300)
committerDavid Bremner <david@tethera.net>
Sat, 18 Jul 2020 14:03:29 +0000 (11:03 -0300)
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

index 6073e45c0572a262f83b67d68da7acc89a41d191..173460084e2ce31cb8e31fc878c0377b1676f9e2 100644 (file)
@@ -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);