diff options
author | Matthew Barnes <mbarnes@redhat.com> | 2011-05-12 02:44:35 +0800 |
---|---|---|
committer | Rodrigo Moya <rodrigo@gnome-db.org> | 2011-06-30 00:42:12 +0800 |
commit | 7142b684b30e37c9e614acdccfcf5968147d15e6 (patch) | |
tree | 19ba7269b61636397733aacb1c6ba94685f6d8a0 /mail | |
parent | fb38ed0bf5891b343afd30a5621d0008cd1e687d (diff) | |
download | gsoc2013-evolution-7142b684b30e37c9e614acdccfcf5968147d15e6.tar.gz gsoc2013-evolution-7142b684b30e37c9e614acdccfcf5968147d15e6.tar.zst gsoc2013-evolution-7142b684b30e37c9e614acdccfcf5968147d15e6.zip |
Fix some GPtrArray leaks.
Diffstat (limited to 'mail')
-rw-r--r-- | mail/e-mail-folder-pane.c | 22 | ||||
-rw-r--r-- | mail/e-mail-reader.c | 51 |
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 |