aboutsummaryrefslogtreecommitdiffstats
path: root/mail
diff options
context:
space:
mode:
authorNot Zed <NotZed@Ximian.com>2005-02-23 14:09:51 +0800
committerMichael Zucci <zucchi@src.gnome.org>2005-02-23 14:09:51 +0800
commit7cf0ace5df855361ace52dd86be315a3f71fc918 (patch)
treed88bad54a6874318b4a3927518634965aaa39d1c /mail
parentcef26eb8ca03c38050110d3f43623ed79076c5de (diff)
downloadgsoc2013-evolution-7cf0ace5df855361ace52dd86be315a3f71fc918.tar
gsoc2013-evolution-7cf0ace5df855361ace52dd86be315a3f71fc918.tar.gz
gsoc2013-evolution-7cf0ace5df855361ace52dd86be315a3f71fc918.tar.bz2
gsoc2013-evolution-7cf0ace5df855361ace52dd86be315a3f71fc918.tar.lz
gsoc2013-evolution-7cf0ace5df855361ace52dd86be315a3f71fc918.tar.xz
gsoc2013-evolution-7cf0ace5df855361ace52dd86be315a3f71fc918.tar.zst
gsoc2013-evolution-7cf0ace5df855361ace52dd86be315a3f71fc918.zip
** See bug #72337
2005-02-21 Not Zed <NotZed@Ximian.com> ** See bug #72337 * mail-component.c (store_info_new, store_info_unref): refcount the storeinfo's. (mc_add_store_done): noop if removed. (store_hash_free, mail_component_remove_store): mark storeinfo removed. svn path=/trunk/; revision=28855
Diffstat (limited to 'mail')
-rw-r--r--mail/ChangeLog10
-rw-r--r--mail/mail-component.c38
2 files changed, 40 insertions, 8 deletions
diff --git a/mail/ChangeLog b/mail/ChangeLog
index f4bc803a16..6e96fb15ba 100644
--- a/mail/ChangeLog
+++ b/mail/ChangeLog
@@ -1,5 +1,15 @@
2005-02-21 Not Zed <NotZed@Ximian.com>
+ ** See bug #72337
+
+ * mail-component.c (store_info_new, store_info_unref): refcount
+ the storeinfo's.
+ (mc_add_store_done): noop if removed.
+ (store_hash_free, mail_component_remove_store): mark storeinfo
+ removed.
+
+2005-02-21 Not Zed <NotZed@Ximian.com>
+
** See bug #70718
* em-folder-view.c (emfv_list_built): handle list_built events -
diff --git a/mail/mail-component.c b/mail/mail-component.c
index e51a30268c..f22e88210c 100644
--- a/mail/mail-component.c
+++ b/mail/mail-component.c
@@ -102,6 +102,9 @@ struct _store_info {
/* for setup only */
void (*done)(CamelStore *store, CamelFolderInfo *info, void *data);
void *done_data;
+
+ int ref_count:31;
+ int removed:1;
};
struct _MailComponentPrivate {
@@ -148,6 +151,7 @@ store_info_new(CamelStore *store, const char *name)
struct _store_info *si;
si = g_malloc0(sizeof(*si));
+ si->ref_count = 1;
if (name == NULL)
si->name = camel_service_get_name((CamelService *)store, TRUE);
else
@@ -165,8 +169,19 @@ store_info_new(CamelStore *store, const char *name)
}
static void
-store_info_free(struct _store_info *si)
+store_info_ref(struct _store_info *si)
+{
+ si->ref_count++;
+}
+
+static void
+store_info_unref(struct _store_info *si)
{
+ if (si->ref_count > 1) {
+ si->ref_count--;
+ return;
+ }
+
if (si->vtrash)
camel_object_unref(si->vtrash);
if (si->vjunk)
@@ -184,11 +199,15 @@ mc_add_store_done(CamelStore *store, CamelFolderInfo *info, void *data)
if (si->done)
si->done(store, info, si);
- /* let the counters know about the already opened junk/trash folders */
- if (si->vtrash)
- mail_note_folder(si->vtrash);
- if (si->vjunk)
- mail_note_folder(si->vjunk);
+ if (!si->removed) {
+ /* let the counters know about the already opened junk/trash folders */
+ if (si->vtrash)
+ mail_note_folder(si->vtrash);
+ if (si->vjunk)
+ mail_note_folder(si->vjunk);
+ }
+
+ store_info_unref(si);
}
/* Utility functions. */
@@ -203,6 +222,7 @@ mc_add_store(MailComponent *component, CamelStore *store, const char *name, void
si->done = done;
g_hash_table_insert(component->priv->store_hash, store, si);
em_folder_tree_model_add_store(component->priv->model, store, si->name);
+ store_info_ref(si);
mail_note_store(store, NULL, mc_add_store_done, si);
}
@@ -429,7 +449,8 @@ impl_dispose (GObject *object)
static void
store_hash_free (CamelStore *store, struct _store_info *si, void *data)
{
- store_info_free(si);
+ si->removed = 1;
+ store_info_unref(si);
}
static void
@@ -1029,7 +1050,8 @@ mail_component_remove_store (MailComponent *component, CamelStore *store)
return;
g_hash_table_remove (priv->store_hash, store);
- store_info_free(si);
+ si->removed = 1;
+ store_info_unref(si);
/* so i guess potentially we could have a race, add a store while one
being removed. ?? */