aboutsummaryrefslogtreecommitdiffstats
path: root/widgets/misc
diff options
context:
space:
mode:
authorMilan Crha <mcrha@redhat.com>2011-03-02 22:12:02 +0800
committerMilan Crha <mcrha@redhat.com>2011-03-02 22:13:40 +0800
commit2533e52b8cf543eed874d220a3f039eebe67253e (patch)
tree20b018e5f1b86200982fd7bb324aef3358469070 /widgets/misc
parenta0854ec1a6591ea10ba7915f37684f78f476fcd4 (diff)
downloadgsoc2013-evolution-2533e52b8cf543eed874d220a3f039eebe67253e.tar
gsoc2013-evolution-2533e52b8cf543eed874d220a3f039eebe67253e.tar.gz
gsoc2013-evolution-2533e52b8cf543eed874d220a3f039eebe67253e.tar.bz2
gsoc2013-evolution-2533e52b8cf543eed874d220a3f039eebe67253e.tar.lz
gsoc2013-evolution-2533e52b8cf543eed874d220a3f039eebe67253e.tar.xz
gsoc2013-evolution-2533e52b8cf543eed874d220a3f039eebe67253e.tar.zst
gsoc2013-evolution-2533e52b8cf543eed874d220a3f039eebe67253e.zip
Do not leak attachments in a mail view
Diffstat (limited to 'widgets/misc')
-rw-r--r--widgets/misc/e-attachment-paned.c1
-rw-r--r--widgets/misc/e-attachment-store.c36
-rw-r--r--widgets/misc/e-attachment-store.h1
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,