aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2013-06-15 20:19:27 +0800
committerMatthew Barnes <mbarnes@redhat.com>2013-06-15 20:19:27 +0800
commitf642e03d4967c80aaad45475475752264c95de5c (patch)
tree23b2f4e862f73b86e13f92c433b8315d783b1d2e
parent2f43685f591581bc7ad051ac6464799f8e5df5bf (diff)
downloadgsoc2013-evolution-f642e03d4967c80aaad45475475752264c95de5c.tar.gz
gsoc2013-evolution-f642e03d4967c80aaad45475475752264c95de5c.tar.zst
gsoc2013-evolution-f642e03d4967c80aaad45475475752264c95de5c.zip
message_list_get_selected: Give the returned array a free func.
The returned UID array now has a built-in "free" function for its elements and should be released by callers with g_ptr_array_unref() rather than em_utils_uids_free() or some equivalent.
-rw-r--r--libemail-engine/mail-ops.c8
-rw-r--r--mail/e-mail-folder-pane.c4
-rw-r--r--mail/e-mail-reader-utils.c27
-rw-r--r--mail/e-mail-reader.c43
-rw-r--r--mail/em-utils.c7
-rw-r--r--mail/message-list.c36
-rw-r--r--modules/mail/e-mail-shell-view-actions.c8
-rw-r--r--modules/mail/e-mail-shell-view-private.c2
-rw-r--r--plugins/mail-to-task/mail-to-task.c8
-rw-r--r--plugins/mailing-list-actions/mailing-list-actions.c2
-rw-r--r--plugins/templates/templates.c2
11 files changed, 58 insertions, 89 deletions
diff --git a/libemail-engine/mail-ops.c b/libemail-engine/mail-ops.c
index 2eb0dae853..64ef0654ae 100644
--- a/libemail-engine/mail-ops.c
+++ b/libemail-engine/mail-ops.c
@@ -177,7 +177,7 @@ em_filter_folder_element_free (struct _filter_mail_msg *m)
g_object_unref (m->source_folder);
if (m->source_uids)
- em_utils_uids_free (m->source_uids);
+ g_ptr_array_unref (m->source_uids);
if (m->destination)
g_object_unref (m->destination);
@@ -206,7 +206,7 @@ mail_filter_folder (EMailSession *session,
m = mail_msg_new (&em_filter_folder_element_info);
m->session = g_object_ref (session);
m->source_folder = g_object_ref (source_folder);
- m->source_uids = uids;
+ m->source_uids = g_ptr_array_ref (uids);
m->cache = NULL;
m->delete = FALSE;
@@ -1149,7 +1149,7 @@ transfer_messages_free (struct _transfer_msg *m)
g_object_unref (m->session);
g_object_unref (m->source);
g_free (m->dest_uri);
- em_utils_uids_free (m->uids);
+ g_ptr_array_unref (m->uids);
}
static MailMsgInfo transfer_messages_info = {
@@ -1180,7 +1180,7 @@ mail_transfer_messages (EMailSession *session,
m = mail_msg_new (&transfer_messages_info);
m->session = g_object_ref (session);
m->source = g_object_ref (source);
- m->uids = uids;
+ m->uids = g_ptr_array_ref (uids);
m->delete = delete_from_source;
m->dest_uri = g_strdup (dest_uri);
m->dest_flags = dest_flags;
diff --git a/mail/e-mail-folder-pane.c b/mail/e-mail-folder-pane.c
index 5da74e4e7b..5c1ef76806 100644
--- a/mail/e-mail-folder-pane.c
+++ b/mail/e-mail-folder-pane.c
@@ -88,10 +88,6 @@ mail_paned_view_open_selected_mail (EMailPanedView *view)
shell = e_shell_backend_get_shell (E_SHELL_BACKEND (backend));
registry = e_shell_get_registry (shell);
- /* XXX Either e_mail_reader_get_selected_uids()
- * or MessageList should do this itself. */
- g_ptr_array_set_free_func (uids, (GDestroyNotify) g_free);
-
if (!em_utils_ask_open_many (window, uids->len))
goto exit;
diff --git a/mail/e-mail-reader-utils.c b/mail/e-mail-reader-utils.c
index 2cd9f96351..b50a06b42e 100644
--- a/mail/e-mail-reader-utils.c
+++ b/mail/e-mail-reader-utils.c
@@ -764,7 +764,7 @@ e_mail_reader_mark_selected (EMailReader *reader,
camel_folder_set_message_flags (
folder, uids->pdata[ii], mask, set);
- em_utils_uids_free (uids);
+ g_ptr_array_unref (uids);
camel_folder_thaw (folder);
@@ -829,12 +829,11 @@ e_mail_reader_open_selected (EMailReader *reader)
em_utils_folder_is_outbox (registry, folder) ||
em_utils_folder_is_templates (registry, folder)) {
- /* FIXME This is leaking the UID array. Give
- * the array a "free func" and unref it. */
e_mail_reader_edit_messages (reader, folder, uids, TRUE, TRUE);
- g_clear_object (&folder);
- return uids->len;
+ ii = uids->len;
+
+ goto exit;
}
views = g_ptr_array_new ();
@@ -906,7 +905,7 @@ e_mail_reader_open_selected (EMailReader *reader)
exit:
g_clear_object (&folder);
- em_utils_uids_free (uids);
+ g_ptr_array_unref (uids);
return ii;
}
@@ -1121,10 +1120,6 @@ e_mail_reader_remove_attachments (EMailReader *reader)
uids = e_mail_reader_get_selected_uids (reader);
g_return_if_fail (uids != NULL);
- /* XXX Either e_mail_reader_get_selected_uids()
- * or MessageList should do this itself. */
- g_ptr_array_set_free_func (uids, (GDestroyNotify) g_free);
-
/* Remove attachments asynchronously. */
activity = e_mail_reader_new_activity (reader);
@@ -1264,10 +1259,6 @@ e_mail_reader_remove_duplicates (EMailReader *reader)
uids = e_mail_reader_get_selected_uids (reader);
g_return_if_fail (uids != NULL);
- /* XXX Either e_mail_reader_get_selected_uids()
- * or MessageList should do this itself. */
- g_ptr_array_set_free_func (uids, (GDestroyNotify) g_free);
-
/* Find duplicate messages asynchronously. */
activity = e_mail_reader_new_activity (reader);
@@ -2042,10 +2033,6 @@ e_mail_reader_save_messages (EMailReader *reader)
message_uid = g_ptr_array_index (uids, 0);
- /* XXX Either e_mail_reader_get_selected_uids()
- * or MessageList should do this itself. */
- g_ptr_array_set_free_func (uids, (GDestroyNotify) g_free);
-
title = ngettext ("Save Message", "Save Messages", uids->len);
/* Suggest as a filename the subject of the first message. */
@@ -2246,7 +2233,7 @@ e_mail_reader_create_filter_from_selected (EMailReader *reader,
g_object_unref (activity);
- em_utils_uids_free (uids);
+ g_ptr_array_unref (uids);
g_object_unref (folder);
}
@@ -2363,7 +2350,7 @@ e_mail_reader_create_vfolder_from_selected (EMailReader *reader,
g_object_unref (activity);
- em_utils_uids_free (uids);
+ g_ptr_array_unref (uids);
}
static void
diff --git a/mail/e-mail-reader.c b/mail/e-mail-reader.c
index 598be3a5f2..449879a173 100644
--- a/mail/e-mail-reader.c
+++ b/mail/e-mail-reader.c
@@ -203,7 +203,7 @@ action_mail_add_sender_cb (GtkAction *action,
exit:
if (info != NULL)
camel_folder_free_message_info (folder, info);
- em_utils_uids_free (uids);
+ g_ptr_array_unref (uids);
g_clear_object (&folder);
}
@@ -435,6 +435,7 @@ action_mail_check_for_junk_cb (GtkAction *action,
E_FILTER_SOURCE_JUNKTEST, FALSE);
g_clear_object (&folder);
+ g_ptr_array_unref (uids);
}
static void
@@ -487,20 +488,16 @@ action_mail_copy_cb (GtkAction *action,
g_free (default_xfer_messages_uri);
default_xfer_messages_uri = g_strdup (uri);
- if (uri != NULL) {
+ if (uri != NULL)
mail_transfer_messages (
session, folder, uids,
FALSE, uri, 0, NULL, NULL);
- uids = NULL;
- }
exit:
- if (uids != NULL)
- em_utils_uids_free (uids);
-
gtk_widget_destroy (dialog);
g_clear_object (&folder);
+ g_ptr_array_unref (uids);
}
static void
@@ -568,6 +565,7 @@ action_mail_filters_apply_cb (GtkAction *action,
E_FILTER_SOURCE_DEMAND, FALSE);
g_clear_object (&folder);
+ g_ptr_array_unref (uids);
}
static void
@@ -610,6 +608,7 @@ action_mail_flag_clear_cb (GtkAction *action,
e_mail_display_reload (display);
g_clear_object (&folder);
+ g_ptr_array_unref (uids);
}
static void
@@ -631,6 +630,7 @@ action_mail_flag_completed_cb (GtkAction *action,
e_mail_display_reload (display);
g_clear_object (&folder);
+ g_ptr_array_unref (uids);
}
static void
@@ -646,6 +646,7 @@ action_mail_flag_for_followup_cb (GtkAction *action,
em_utils_flag_for_followup (reader, folder, uids);
g_clear_object (&folder);
+ g_ptr_array_unref (uids);
}
static void
@@ -659,10 +660,6 @@ action_mail_forward_cb (GtkAction *action,
uids = e_mail_reader_get_selected_uids (reader);
g_return_if_fail (uids != NULL);
- /* XXX Either e_mail_reader_get_selected_uids()
- * or MessageList should do this itself. */
- g_ptr_array_set_free_func (uids, (GDestroyNotify) g_free);
-
if (em_utils_ask_open_many (window, uids->len)) {
CamelFolder *folder;
@@ -689,10 +686,6 @@ action_mail_forward_attached_cb (GtkAction *action,
uids = e_mail_reader_get_selected_uids (reader);
g_return_if_fail (uids != NULL);
- /* XXX Either e_mail_reader_get_selected_uids()
- * or MessageList should do this itself. */
- g_ptr_array_set_free_func (uids, (GDestroyNotify) g_free);
-
if (em_utils_ask_open_many (window, uids->len)) {
CamelFolder *folder;
@@ -719,10 +712,6 @@ action_mail_forward_inline_cb (GtkAction *action,
uids = e_mail_reader_get_selected_uids (reader);
g_return_if_fail (uids != NULL);
- /* XXX Either e_mail_reader_get_selected_uids()
- * or MessageList should do this itself. */
- g_ptr_array_set_free_func (uids, (GDestroyNotify) g_free);
-
if (em_utils_ask_open_many (window, uids->len)) {
CamelFolder *folder;
@@ -749,10 +738,6 @@ action_mail_forward_quoted_cb (GtkAction *action,
uids = e_mail_reader_get_selected_uids (reader);
g_return_if_fail (uids != NULL);
- /* XXX Either e_mail_reader_get_selected_uids()
- * or MessageList should do this itself. */
- g_ptr_array_set_free_func (uids, (GDestroyNotify) g_free);
-
if (em_utils_ask_open_many (window, uids->len)) {
CamelFolder *folder;
@@ -915,10 +900,6 @@ action_mail_message_edit_cb (GtkAction *action,
shell = e_shell_backend_get_shell (E_SHELL_BACKEND (backend));
registry = e_shell_get_registry (shell);
- /* XXX Either e_mail_reader_get_selected_uids()
- * or MessageList should do this itself. */
- g_ptr_array_set_free_func (uids, (GDestroyNotify) g_free);
-
folder = e_mail_reader_ref_folder (reader);
replace = em_utils_folder_is_drafts (registry, folder);
e_mail_reader_edit_messages (reader, folder, uids, replace, replace);
@@ -1016,7 +997,7 @@ action_mail_move_cb (GtkAction *action,
exit:
if (uids != NULL)
- em_utils_uids_free (uids);
+ g_ptr_array_unref (uids);
gtk_widget_destroy (dialog);
@@ -1829,7 +1810,7 @@ action_mail_show_source_cb (GtkAction *action,
g_object_unref (activity);
- em_utils_uids_free (uids);
+ g_ptr_array_unref (uids);
g_clear_object (&folder);
}
@@ -1864,7 +1845,7 @@ action_mail_toggle_important_cb (GtkAction *action,
camel_folder_thaw (folder);
g_clear_object (&folder);
- em_utils_uids_free (uids);
+ g_ptr_array_unref (uids);
}
static void
@@ -4263,7 +4244,7 @@ e_mail_reader_check_state (EMailReader *reader)
state |= E_MAIL_READER_FOLDER_IS_JUNK;
g_clear_object (&folder);
- em_utils_uids_free (uids);
+ g_ptr_array_unref (uids);
return state;
}
diff --git a/mail/em-utils.c b/mail/em-utils.c
index 103ed62b1a..16a0d677ae 100644
--- a/mail/em-utils.c
+++ b/mail/em-utils.c
@@ -431,9 +431,6 @@ em_utils_flag_for_followup (EMailReader *reader,
e_mail_display_reload (display);
exit:
- /* XXX We shouldn't be freeing this. */
- em_utils_uids_free (uids);
-
gtk_widget_destroy (GTK_WIDGET (editor));
}
@@ -470,8 +467,6 @@ em_utils_flag_for_followup_clear (GtkWindow *parent,
}
camel_folder_thaw (folder);
-
- em_utils_uids_free (uids);
}
/**
@@ -514,8 +509,6 @@ em_utils_flag_for_followup_completed (GtkWindow *parent,
camel_folder_thaw (folder);
g_free (now);
-
- em_utils_uids_free (uids);
}
/* This kind of sucks, because for various reasons most callers need to run
diff --git a/mail/message-list.c b/mail/message-list.c
index 7657cc13b2..b0fd942679 100644
--- a/mail/message-list.c
+++ b/mail/message-list.c
@@ -550,14 +550,12 @@ static void
clear_selection (MessageList *message_list,
struct _MLSelection *selection)
{
- if (selection->uids) {
- em_utils_uids_free (selection->uids);
+ if (selection->uids != NULL) {
+ g_ptr_array_unref (selection->uids);
selection->uids = NULL;
}
- if (selection->folder) {
- g_object_unref (selection->folder);
- selection->folder = NULL;
- }
+
+ g_clear_object (&selection->folder);
}
static ETreePath
@@ -1052,18 +1050,20 @@ message_list_copy (MessageList *message_list,
g_object_unref (folder);
}
- p->clipboard.uids = uids;
+ p->clipboard.uids = g_ptr_array_ref (uids);
p->clipboard.folder = message_list_ref_folder (message_list);
+
gtk_selection_owner_set (
p->invisible,
GDK_SELECTION_CLIPBOARD,
gtk_get_current_event_time ());
} else {
- em_utils_uids_free (uids);
gtk_selection_owner_set (
NULL, GDK_SELECTION_CLIPBOARD,
gtk_get_current_event_time ());
}
+
+ g_ptr_array_unref (uids);
}
void
@@ -2328,7 +2328,7 @@ ml_tree_drag_data_get (ETree *tree,
}
g_clear_object (&folder);
- em_utils_uids_free (uids);
+ g_ptr_array_unref (uids);
}
/* TODO: merge this with the folder tree stuff via empopup targets */
@@ -3533,7 +3533,9 @@ build_tree (MessageList *message_list,
saveuid = find_next_selectable (message_list);
selected = message_list_get_selected (message_list);
+
e_tree_memory_freeze (E_TREE_MEMORY (etm));
+
clear_tree (message_list, FALSE);
build_subtree (
@@ -3552,7 +3554,8 @@ build_tree (MessageList *message_list,
e_tree_memory_freeze (E_TREE_MEMORY (etm));
message_list_set_selected (message_list, selected);
- em_utils_uids_free (selected);
+
+ g_ptr_array_unref (selected);
/* Show the cursor unless we're responding to a
* "folder-changed" signal from our CamelFolder. */
@@ -3841,16 +3844,22 @@ build_flat (MessageList *message_list,
saveuid = find_next_selectable (message_list);
selected = message_list_get_selected (message_list);
+
e_tree_memory_freeze (E_TREE_MEMORY (etm));
+
clear_tree (message_list, FALSE);
+
for (i = 0; i < summary->len; i++) {
CamelMessageInfo *info = summary->pdata[i];
ml_uid_nodemap_insert (message_list, info, NULL, -1);
}
+
e_tree_memory_thaw (E_TREE_MEMORY (etm));
+
message_list_set_selected (message_list, selected);
- em_utils_uids_free (selected);
+
+ g_ptr_array_unref (selected);
if (saveuid) {
ETreePath node;
@@ -4343,6 +4352,7 @@ on_selection_changed_cmd (ETree *tree,
/* not sure if we could just ignore this for the cursor, i think sometimes you
* only get a selection changed when you should also get a cursor activated? */
uids = message_list_get_selected (message_list);
+
if (uids->len == 1)
newuid = g_ptr_array_index (uids, 0);
else if ((cursor = e_tree_get_cursor (tree)))
@@ -4368,7 +4378,7 @@ on_selection_changed_cmd (ETree *tree,
message_list->last_sel_single = uids->len == 1;
- em_utils_uids_free (uids);
+ g_ptr_array_unref (uids);
}
static gint
@@ -4496,6 +4506,8 @@ message_list_get_selected (MessageList *message_list)
g_ptr_array_new ()
};
+ g_ptr_array_set_free_func (data.uids, (GDestroyNotify) g_free);
+
e_tree_selected_path_foreach (
E_TREE (message_list), ml_getselected_cb, &data);
diff --git a/modules/mail/e-mail-shell-view-actions.c b/modules/mail/e-mail-shell-view-actions.c
index 4056a7b08f..c8bec966d2 100644
--- a/modules/mail/e-mail-shell-view-actions.c
+++ b/modules/mail/e-mail-shell-view-actions.c
@@ -1007,7 +1007,7 @@ action_mail_label_cb (GtkToggleAction *action,
camel_folder_thaw (folder);
g_clear_object (&folder);
- em_utils_uids_free (uids);
+ g_ptr_array_unref (uids);
}
static void
@@ -1080,7 +1080,7 @@ action_mail_label_new_cb (GtkAction *action,
folder, uids->pdata[ii], label_tag, TRUE);
g_clear_object (&folder);
- em_utils_uids_free (uids);
+ g_ptr_array_unref (uids);
g_free (label_tag);
@@ -1143,7 +1143,7 @@ action_mail_label_none_cb (GtkAction *action,
}
g_clear_object (&folder);
- em_utils_uids_free (uids);
+ g_ptr_array_unref (uids);
}
static void
@@ -2390,7 +2390,7 @@ e_mail_shell_view_update_popup_labels (EMailShellView *mail_shell_view)
ii++;
}
- em_utils_uids_free (uids);
+ g_ptr_array_unref (uids);
}
void
diff --git a/modules/mail/e-mail-shell-view-private.c b/modules/mail/e-mail-shell-view-private.c
index 16971771de..61cfd8b7ac 100644
--- a/modules/mail/e-mail-shell-view-private.c
+++ b/modules/mail/e-mail-shell-view-private.c
@@ -1086,7 +1086,7 @@ e_mail_shell_view_update_sidebar (EMailShellView *mail_shell_view)
num_visible), num_visible);
}
- em_utils_uids_free (uids);
+ g_ptr_array_unref (uids);
uid = camel_service_get_uid (CAMEL_SERVICE (parent_store));
store_is_local = (g_strcmp0 (uid, E_MAIL_SESSION_LOCAL_UID) == 0);
diff --git a/plugins/mail-to-task/mail-to-task.c b/plugins/mail-to-task/mail-to-task.c
index 12ff5b0c95..be27242544 100644
--- a/plugins/mail-to-task/mail-to-task.c
+++ b/plugins/mail-to-task/mail-to-task.c
@@ -1035,7 +1035,7 @@ do_mail_to_event (AsyncData *data)
/* free memory */
if (client != NULL)
g_object_unref (client);
- em_utils_uids_free (uids);
+ g_ptr_array_unref (uids);
g_object_unref (folder);
g_object_unref (data->source);
@@ -1127,7 +1127,7 @@ mail_to_event (ECalClientSourceType source_type,
g_free (question);
if (response == GTK_RESPONSE_NO) {
- em_utils_uids_free (uids);
+ g_ptr_array_unref (uids);
return;
}
}
@@ -1195,7 +1195,6 @@ mail_to_event (ECalClientSourceType source_type,
} else if (!source) {
e_notice (NULL, GTK_MESSAGE_ERROR, _("No writable calendar is available."));
- em_utils_uids_free (uids);
if (error)
g_error_free (error);
goto exit;
@@ -1212,7 +1211,7 @@ mail_to_event (ECalClientSourceType source_type,
data->source = g_object_ref (source);
data->source_type = source_type;
data->folder = e_mail_reader_ref_folder (reader);
- data->uids = uids;
+ data->uids = g_ptr_array_ref (uids);
data->with_attendees = with_attendees;
if (uids->len == 1)
@@ -1232,6 +1231,7 @@ mail_to_event (ECalClientSourceType source_type,
exit:
g_object_unref (default_source);
+ g_ptr_array_unref (uids);
}
static void
diff --git a/plugins/mailing-list-actions/mailing-list-actions.c b/plugins/mailing-list-actions/mailing-list-actions.c
index efbe222307..e390e9dd2e 100644
--- a/plugins/mailing-list-actions/mailing-list-actions.c
+++ b/plugins/mailing-list-actions/mailing-list-actions.c
@@ -316,7 +316,7 @@ emla_list_action (EMailReader *reader,
g_clear_object (&folder);
- em_utils_uids_free (uids);
+ g_ptr_array_unref (uids);
}
static void
diff --git a/plugins/templates/templates.c b/plugins/templates/templates.c
index d83e1fbe17..95d006028e 100644
--- a/plugins/templates/templates.c
+++ b/plugins/templates/templates.c
@@ -1040,7 +1040,7 @@ action_reply_with_template_cb (GtkAction *action,
g_clear_object (&folder);
- em_utils_uids_free (uids);
+ g_ptr_array_unref (uids);
}
static void