diff options
author | Milan Crha <mcrha@redhat.com> | 2010-09-29 17:02:35 +0800 |
---|---|---|
committer | Milan Crha <mcrha@redhat.com> | 2010-09-29 17:02:35 +0800 |
commit | a28f6db7fcf20a618675d26bbd7072164b9d4c8c (patch) | |
tree | 1a4b15b9169b37452af94d49058a968edaae1af7 | |
parent | 5b154c62991000a2d6bab1c426f6bce4d95a658f (diff) | |
download | gsoc2013-evolution-a28f6db7fcf20a618675d26bbd7072164b9d4c8c.tar gsoc2013-evolution-a28f6db7fcf20a618675d26bbd7072164b9d4c8c.tar.gz gsoc2013-evolution-a28f6db7fcf20a618675d26bbd7072164b9d4c8c.tar.bz2 gsoc2013-evolution-a28f6db7fcf20a618675d26bbd7072164b9d4c8c.tar.lz gsoc2013-evolution-a28f6db7fcf20a618675d26bbd7072164b9d4c8c.tar.xz gsoc2013-evolution-a28f6db7fcf20a618675d26bbd7072164b9d4c8c.tar.zst gsoc2013-evolution-a28f6db7fcf20a618675d26bbd7072164b9d4c8c.zip |
Bug #629266 - Crash on search in Current Account
-rw-r--r-- | modules/mail/e-mail-shell-view.c | 61 |
1 files changed, 54 insertions, 7 deletions
diff --git a/modules/mail/e-mail-shell-view.c b/modules/mail/e-mail-shell-view.c index b95153ed42..4d0bb6ac91 100644 --- a/modules/mail/e-mail-shell-view.c +++ b/modules/mail/e-mail-shell-view.c @@ -665,18 +665,65 @@ current_account: /* Create a new search folder. */ - store = camel_folder_get_parent_store (folder); + if (folder) { + store = camel_folder_get_parent_store (folder); + } else { + GtkTreeView *tree_view; + GtkTreeSelection *selection; + GtkTreeModel *model; + GtkTreeIter iter; + + store = NULL; + tree_view = GTK_TREE_VIEW (folder_tree); + selection = gtk_tree_view_get_selection (tree_view); + + if (gtk_tree_selection_get_selected (selection, &model, &iter)) + gtk_tree_model_get (model, &iter, COL_POINTER_CAMEL_STORE, &store, -1); + } + list = NULL; /* list of CamelFolders */ - if (store->folders != NULL) { - GPtrArray *array; - guint ii; + if (store) { + CamelFolderInfo *root, *fi; + + root = camel_store_get_folder_info_sync (store, NULL, CAMEL_STORE_FOLDER_INFO_RECURSIVE, NULL, NULL); + fi = root; + while (fi) { + CamelFolderInfo *next; + + if ((fi->flags & CAMEL_FOLDER_NOSELECT) == 0) { + CamelFolder *fldr; + + fldr = camel_store_get_folder_sync (store, fi->full_name, 0, NULL, NULL); + if (fldr) + list = g_list_prepend (list, fldr); + } + + /* pick the next */ + next = fi->child; + if (!next) + next = fi->next; + if (!next) { + next = fi->parent; + while (next) { + if (next->next) { + next = next->next; + break; + } + + next = next->parent; + } + } - array = camel_object_bag_list (store->folders); - for (ii = 0; ii < array->len; ii++) - list = g_list_append (list, array->pdata[ii]); + fi = next; + } + + if (root) + camel_store_free_folder_info_full (store, root); } + list = g_list_reverse (list); + /* FIXME Using data_dir like this is not portable. */ uri = g_strdup_printf ("vfolder:%s/vfolder", data_dir); store = camel_session_get_store (session, uri, NULL); |