]> git.cworth.org Git - notmuch/blobdiff - lib/thread.cc
lib: break reference loop by choosing arbitrary top level msg
[notmuch] / lib / thread.cc
index 1632da4cd0f4f9398e774b8157004e89914485d9..dbac002fd7130c4c7559dcf96fbb9b90bdab2487 100644 (file)
@@ -160,6 +160,9 @@ _resolve_thread_authors_string (notmuch_thread_t *thread)
     thread->authors_array = NULL;
     g_ptr_array_free (thread->matched_authors_array, true);
     thread->matched_authors_array = NULL;
+
+    if (!thread->authors)
+       thread->authors = talloc_strdup(thread, "");
 }
 
 /* clean up the ugly "Lastname, Firstname" format that some mail systems
@@ -394,7 +397,13 @@ _resolve_thread_relationships (notmuch_thread_t *thread)
     for (node = thread->message_list->head; node; node = node->next) {
        message = node->message;
        in_reply_to = _notmuch_message_get_in_reply_to (message);
-       if (in_reply_to && strlen (in_reply_to) &&
+       /*
+        * if we reach the end of the list without finding a top-level
+        * message, that means the thread is a cycle (or set of
+        * cycles) and any message can be considered top-level
+        */
+       if ((thread->toplevel_list->head || node->next) &&
+            in_reply_to && strlen (in_reply_to) &&
            g_hash_table_lookup_extended (thread->message_hash,
                                          in_reply_to, NULL,
                                          (void **) &parent))