diff --git a/src/db.cc b/src/db.cc index 26e2c7ef2..bb30ab8db 100644 --- a/src/db.cc +++ b/src/db.cc @@ -451,7 +451,6 @@ namespace Astroid { string query_s = "thread:" + thread_id; notmuch_query_t * query = notmuch_query_create (nm_db, query_s.c_str()); - notmuch_thread_t * nm_thread; notmuch_threads_t * nm_threads; notmuch_status_t st = NOTMUCH_STATUS_SUCCESS; @@ -469,13 +468,8 @@ namespace Astroid { int c = 0; for ( ; notmuch_threads_valid (nm_threads); notmuch_threads_move_to_next (nm_threads)) { - if (c > 0) { - LOG (error) << "db: got more than one thread for thread id."; - throw invalid_argument ("db: got more than one thread for thread id."); - } - - nm_thread = notmuch_threads_get (nm_threads); - + notmuch_thread_t* nm_thread = notmuch_threads_get (nm_threads); + func (nm_thread); c++; } @@ -486,9 +480,6 @@ namespace Astroid { return; } - /* call function */ - func (nm_thread); - /* free resources */ notmuch_query_destroy (query); } diff --git a/src/modes/thread_index/query_loader.cc b/src/modes/thread_index/query_loader.cc index 40f384ba3..8a5167ff7 100644 --- a/src/modes/thread_index/query_loader.cc +++ b/src/modes/thread_index/query_loader.cc @@ -336,35 +336,31 @@ namespace Astroid { Gtk::TreeViewColumn *c; list_view->get_cursor (path, c); - auto iter = list_store->prepend (); - Gtk::ListStore::Row newrow = *iter; - NotmuchThread * t; - - db->on_thread (thread_id, [&t](notmuch_thread_t *nmt) { - - t = new NotmuchThread (nmt); - - }); - - newrow[list_store->columns.newest_date] = t->newest_date; - newrow[list_store->columns.oldest_date] = t->oldest_date; - newrow[list_store->columns.thread_id] = t->thread_id; - newrow[list_store->columns.thread] = Glib::RefPtr(t); - - /* check if we should select it (if this is the only item) */ - if (list_store->children().size() == 1) { - if (!in_destructor) - first_thread_ready.emit (); - } else { - - if (path == Gtk::TreePath ("0")) { - Gtk::TreePath addpath = list_store->get_path (iter); - if (addpath <= path) { - list_view->set_cursor (addpath); + db->on_thread (thread_id, [this, &path](notmuch_thread_t *nmt) { + auto iter = list_store->prepend(); + Gtk::ListStore::Row newrow = *iter; + NotmuchThread* t = new NotmuchThread (nmt); + + newrow[list_store->columns.newest_date] = t->newest_date; + newrow[list_store->columns.oldest_date] = t->oldest_date; + newrow[list_store->columns.thread_id] = t->thread_id; + newrow[list_store->columns.thread] = Glib::RefPtr(t); + + /* check if we should select it (if this is the only item) */ + if (list_store->children().size() == 1) { + if (!in_destructor) + first_thread_ready.emit (); + } else { + + if (path == Gtk::TreePath ("0")) { + Gtk::TreePath addpath = list_store->get_path (iter); + if (addpath <= path) { + list_view->set_cursor (addpath); + } + } } - } - } + }); changed = true; }