X-Git-Url: http://git.maemo.org/git/?a=blobdiff_plain;f=src%2Fmodest-search.c;h=3ed4ed6bf2abb18a0ccf3107b1b71d219ed29217;hb=30bcfb889b724cec0d35303c32d6121ef5c94fdb;hp=46d5c90fedc5d89dd376a6b0d6c08480f035e55d;hpb=7de3bb67582c1e534d12efa0a573fb8ca18c1cdb;p=modest diff --git a/src/modest-search.c b/src/modest-search.c index 46d5c90..3ed4ed6 100644 --- a/src/modest-search.c +++ b/src/modest-search.c @@ -356,10 +356,12 @@ static gboolean search_mime_part_and_child_parts (TnyMimePart *part, ModestSearc TnyIterator *piter = tny_list_create_iterator (child_parts); while (!found && !tny_iterator_is_done (piter)) { TnyMimePart *pcur = (TnyMimePart *) tny_iterator_get_current (piter); + if (pcur) { + found = search_mime_part_and_child_parts (pcur, search); - found = search_mime_part_and_child_parts (pcur, search); + g_object_unref (pcur); + } - g_object_unref (pcur); tny_iterator_next (piter); } @@ -418,9 +420,13 @@ modest_search_folder (TnyFolder *folder, ModestSearch *search) while (!tny_iterator_is_done (iter)) { TnyHeader *cur = (TnyHeader *) tny_iterator_get_current (iter); - time_t t = tny_header_get_date_sent (cur); + const time_t t = tny_header_get_date_sent (cur); gboolean found = FALSE; + /* Ignore deleted (not yet expunged) emails: */ + if (tny_header_get_flags(cur) & TNY_HEADER_FLAG_DELETED) + goto go_next; + if (search->flags & MODEST_SEARCH_BEFORE) if (!(t <= search->before)) goto go_next; @@ -486,6 +492,7 @@ modest_search_folder (TnyFolder *folder, ModestSearch *search) retval = add_hit (retval, cur, folder); } } + if (msg) g_object_unref (msg); } @@ -524,24 +531,27 @@ modest_search_account (TnyAccount *account, ModestSearch *search) iter = tny_list_create_iterator (folders); while (!tny_iterator_is_done (iter)) { - TnyFolder *folder; - GList *res; + TnyFolder *folder = NULL; + GList *res = NULL; folder = TNY_FOLDER (tny_iterator_get_current (iter)); - /* g_debug ("DEBUG: %s: searching folder %s.", - __FUNCTION__, tny_folder_get_name (folder)); */ + if (folder) { + /* g_debug ("DEBUG: %s: searching folder %s.", + __FUNCTION__, tny_folder_get_name (folder)); */ - res = modest_search_folder (folder, search); + res = modest_search_folder (folder, search); - if (res != NULL) { - if (hits == NULL) { - hits = res; - } else { - hits = g_list_concat (hits, res); + if (res != NULL) { + if (hits == NULL) { + hits = res; + } else { + hits = g_list_concat (hits, res); + } } + + g_object_unref (folder); } - g_object_unref (folder); tny_iterator_next (iter); } @@ -571,26 +581,26 @@ modest_search_all_accounts (ModestSearch *search) iter = tny_list_create_iterator (accounts); while (!tny_iterator_is_done (iter)) { - TnyAccount *account; - GList *res; + TnyAccount *account = NULL; + GList *res = NULL; account = TNY_ACCOUNT (tny_iterator_get_current (iter)); - - - /* g_debug ("DEBUG: %s: Searching account %s", - __FUNCTION__, tny_account_get_name (account)); */ - res = modest_search_account (account, search); - - if (res != NULL) { + if (account) { + /* g_debug ("DEBUG: %s: Searching account %s", + __FUNCTION__, tny_account_get_name (account)); */ + res = modest_search_account (account, search); - if (hits == NULL) { - hits = res; - } else { - hits = g_list_concat (hits, res); + if (res != NULL) { + if (hits == NULL) { + hits = res; + } else { + hits = g_list_concat (hits, res); + } } - } - g_object_unref (account); + g_object_unref (account); + } + tny_iterator_next (iter); }