diff options
author | Milan Crha <mcrha@redhat.com> | 2011-03-02 22:12:02 +0800 |
---|---|---|
committer | Rodrigo Moya <rodrigo@gnome-db.org> | 2011-06-30 00:41:40 +0800 |
commit | 498337e8524e1acf9f9471fc8c54038341035911 (patch) | |
tree | cae6cdd53705523944e7885b8eb194b0e2863e95 /widgets | |
parent | 623f79123688faa67a52076bd00a1e8885ea8023 (diff) | |
download | gsoc2013-evolution-498337e8524e1acf9f9471fc8c54038341035911.tar gsoc2013-evolution-498337e8524e1acf9f9471fc8c54038341035911.tar.gz gsoc2013-evolution-498337e8524e1acf9f9471fc8c54038341035911.tar.bz2 gsoc2013-evolution-498337e8524e1acf9f9471fc8c54038341035911.tar.lz gsoc2013-evolution-498337e8524e1acf9f9471fc8c54038341035911.tar.xz gsoc2013-evolution-498337e8524e1acf9f9471fc8c54038341035911.tar.zst gsoc2013-evolution-498337e8524e1acf9f9471fc8c54038341035911.zip |
Do not leak attachments in a mail view
Diffstat (limited to 'widgets')
-rw-r--r-- | widgets/misc/e-attachment-paned.c | 1 | ||||
-rw-r--r-- | widgets/misc/e-attachment-store.c | 36 | ||||
-rw-r--r-- | widgets/misc/e-attachment-store.h | 1 |
3 files changed, 33 insertions, 5 deletions
diff --git a/widgets/misc/e-attachment-paned.c b/widgets/misc/e-attachment-paned.c index 21d736b50b..73773f25a1 100644 --- a/widgets/misc/e-attachment-paned.c +++ b/widgets/misc/e-attachment-paned.c @@ -221,6 +221,7 @@ attachment_paned_dispose (GObject *object) priv = E_ATTACHMENT_PANED (object)->priv; if (priv->model != NULL) { + e_attachment_store_remove_all (E_ATTACHMENT_STORE (priv->model)); g_object_unref (priv->model); priv->model = NULL; } diff --git a/widgets/misc/e-attachment-store.c b/widgets/misc/e-attachment-store.c index 392dfe6fc7..e1794d653c 100644 --- a/widgets/misc/e-attachment-store.c +++ b/widgets/misc/e-attachment-store.c @@ -108,11 +108,7 @@ attachment_store_get_property (GObject *object, static void attachment_store_dispose (GObject *object) { - EAttachmentStorePrivate *priv; - - priv = E_ATTACHMENT_STORE (object)->priv; - - g_hash_table_remove_all (priv->attachment_index); + e_attachment_store_remove_all (E_ATTACHMENT_STORE (object)); /* Chain up to parent's dispose() method. */ G_OBJECT_CLASS (e_attachment_store_parent_class)->dispose (object); @@ -327,6 +323,36 @@ e_attachment_store_remove_attachment (EAttachmentStore *store, } void +e_attachment_store_remove_all (EAttachmentStore *store) +{ + GList *list, *iter; + + g_return_if_fail (E_IS_ATTACHMENT_STORE (store)); + + if (!g_hash_table_size (store->priv->attachment_index)) + return; + + g_object_freeze_notify (G_OBJECT (store)); + + list = e_attachment_store_get_attachments (store); + for (iter = list; iter; iter = iter->next) { + EAttachment *attachment = iter->data; + + e_attachment_cancel (attachment); + g_hash_table_remove (store->priv->attachment_index, iter->data); + } + + g_list_foreach (list, (GFunc) g_object_unref, NULL); + g_list_free (list); + + gtk_list_store_clear (GTK_LIST_STORE (store)); + + g_object_notify (G_OBJECT (store), "num-attachments"); + g_object_notify (G_OBJECT (store), "total-size"); + g_object_thaw_notify (G_OBJECT (store)); +} + +void e_attachment_store_add_to_multipart (EAttachmentStore *store, CamelMultipart *multipart, const gchar *default_charset) diff --git a/widgets/misc/e-attachment-store.h b/widgets/misc/e-attachment-store.h index 49980ea3b1..a7839aca71 100644 --- a/widgets/misc/e-attachment-store.h +++ b/widgets/misc/e-attachment-store.h @@ -80,6 +80,7 @@ void e_attachment_store_add_attachment gboolean e_attachment_store_remove_attachment (EAttachmentStore *store, EAttachment *attachment); +void e_attachment_store_remove_all (EAttachmentStore *store); void e_attachment_store_add_to_multipart (EAttachmentStore *store, CamelMultipart *multipart, |