aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2011-05-12 02:44:35 +0800
committerMatthew Barnes <mbarnes@redhat.com>2011-05-12 02:44:35 +0800
commite9b9df5f94c0d9d31972a906606db9ee1db3ad48 (patch)
treee4aeb5a5d773f7ac0b89794abc9d2e0a8c8ca96d
parentba8f1f78f4ec76aeaec6e2b55fcb9b2dec17ba65 (diff)
downloadgsoc2013-evolution-e9b9df5f94c0d9d31972a906606db9ee1db3ad48.tar
gsoc2013-evolution-e9b9df5f94c0d9d31972a906606db9ee1db3ad48.tar.gz
gsoc2013-evolution-e9b9df5f94c0d9d31972a906606db9ee1db3ad48.tar.bz2
gsoc2013-evolution-e9b9df5f94c0d9d31972a906606db9ee1db3ad48.tar.lz
gsoc2013-evolution-e9b9df5f94c0d9d31972a906606db9ee1db3ad48.tar.xz
gsoc2013-evolution-e9b9df5f94c0d9d31972a906606db9ee1db3ad48.tar.zst
gsoc2013-evolution-e9b9df5f94c0d9d31972a906606db9ee1db3ad48.zip
Fix some GPtrArray leaks.
-rw-r--r--mail/e-mail-folder-pane.c22
-rw-r--r--mail/e-mail-reader.c51
2 files changed, 50 insertions, 23 deletions
diff --git a/mail/e-mail-folder-pane.c b/mail/e-mail-folder-pane.c
index 2f1091e11b..0e55fc5653 100644
--- a/mail/e-mail-folder-pane.c
+++ b/mail/e-mail-folder-pane.c
@@ -75,9 +75,14 @@ mail_paned_view_open_selected_mail (EMailPanedView *view)
folder = e_mail_reader_get_folder (reader);
window = e_mail_reader_get_window (reader);
uids = e_mail_reader_get_selected_uids (reader);
+ g_return_val_if_fail (uids != NULL, 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);
if (!em_utils_ask_open_many (window, uids->len)) {
- em_utils_uids_free (uids);
+ g_ptr_array_unref (uids);
return 0;
}
@@ -85,10 +90,12 @@ mail_paned_view_open_selected_mail (EMailPanedView *view)
em_utils_folder_is_outbox (folder) ||
em_utils_folder_is_templates (folder)) {
em_utils_edit_messages (reader, folder, uids, TRUE);
+ g_ptr_array_unref (uids);
return 0;
}
- views = g_ptr_array_new ();
+ views = g_ptr_array_new_with_free_func ((GDestroyNotify) g_free);
+
/* For vfolders we need to edit the original, not the vfolder copy. */
for (ii = 0; ii < uids->len; ii++) {
const gchar *uid = uids->pdata[ii];
@@ -113,10 +120,12 @@ mail_paned_view_open_selected_mail (EMailPanedView *view)
em_utils_folder_is_outbox (real_folder)) {
GPtrArray *edits;
- edits = g_ptr_array_new ();
+ edits = g_ptr_array_new_with_free_func (
+ (GDestroyNotify) g_free);
g_ptr_array_add (edits, real_uid);
em_utils_edit_messages (
reader, real_folder, edits, TRUE);
+ g_ptr_array_unref (edits);
} else {
g_free (real_uid);
g_ptr_array_add (views, g_strdup (uid));
@@ -126,13 +135,12 @@ mail_paned_view_open_selected_mail (EMailPanedView *view)
}
n_views = views->len;
+
for (i = 0; i < n_views; i++)
g_signal_emit_by_name (view, "open-mail", views->pdata[i]);
- g_ptr_array_foreach (views, (GFunc) g_free, NULL);
- g_ptr_array_free (views, TRUE);
-
- em_utils_uids_free (uids);
+ g_ptr_array_unref (views);
+ g_ptr_array_unref (uids);
return n_views;
}
diff --git a/mail/e-mail-reader.c b/mail/e-mail-reader.c
index e18a5467d2..8cca498aec 100644
--- a/mail/e-mail-reader.c
+++ b/mail/e-mail-reader.c
@@ -541,17 +541,20 @@ action_mail_forward_cb (GtkAction *action,
GPtrArray *uids;
folder = e_mail_reader_get_folder (reader);
- uids = e_mail_reader_get_selected_uids (reader);
window = e_mail_reader_get_window (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);
+
if (em_utils_ask_open_many (window, uids->len))
em_utils_forward_messages (
reader, folder, uids,
e_mail_reader_get_forward_style (reader));
- else
- em_utils_uids_free (uids);
+
+ g_ptr_array_unref (uids);
check_close_browser_reader (reader);
}
@@ -565,17 +568,20 @@ action_mail_forward_attached_cb (GtkAction *action,
GPtrArray *uids;
folder = e_mail_reader_get_folder (reader);
- uids = e_mail_reader_get_selected_uids (reader);
window = e_mail_reader_get_window (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);
+
if (em_utils_ask_open_many (window, uids->len))
em_utils_forward_messages (
reader, folder, uids,
E_MAIL_FORWARD_STYLE_ATTACHED);
- else
- em_utils_uids_free (uids);
+
+ g_ptr_array_unref (uids);
check_close_browser_reader (reader);
}
@@ -589,17 +595,20 @@ action_mail_forward_inline_cb (GtkAction *action,
GPtrArray *uids;
folder = e_mail_reader_get_folder (reader);
- uids = e_mail_reader_get_selected_uids (reader);
window = e_mail_reader_get_window (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);
+
if (em_utils_ask_open_many (window, uids->len))
em_utils_forward_messages (
reader, folder, uids,
E_MAIL_FORWARD_STYLE_INLINE);
- else
- em_utils_uids_free (uids);
+
+ g_ptr_array_unref (uids);
check_close_browser_reader (reader);
}
@@ -613,17 +622,20 @@ action_mail_forward_quoted_cb (GtkAction *action,
GPtrArray *uids;
folder = e_mail_reader_get_folder (reader);
- uids = e_mail_reader_get_selected_uids (reader);
window = e_mail_reader_get_window (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);
+
if (em_utils_ask_open_many (window, uids->len))
em_utils_forward_messages (
reader, folder, uids,
E_MAIL_FORWARD_STYLE_QUOTED);
- else
- em_utils_uids_free (uids);
+
+ g_ptr_array_unref (uids);
check_close_browser_reader (reader);
}
@@ -731,9 +743,16 @@ action_mail_message_edit_cb (GtkAction *action,
folder = e_mail_reader_get_folder (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);
replace = em_utils_folder_is_drafts (folder);
em_utils_edit_messages (reader, folder, uids, replace);
+
+ g_ptr_array_unref (uids);
}
static void