diff options
author | Peter Williams <peterw@ximian.com> | 2001-07-06 00:40:45 +0800 |
---|---|---|
committer | Peter Williams <peterw@src.gnome.org> | 2001-07-06 00:40:45 +0800 |
commit | d0eee4860651b7ce2e30f535372773a87db233c1 (patch) | |
tree | d9b9c45f96b8cc1bf255301c9005e0a2a6254fae /camel | |
parent | fb6a190f0085747e1146bc2f9153753fb95dd94b (diff) | |
download | gsoc2013-evolution-d0eee4860651b7ce2e30f535372773a87db233c1.tar.gz gsoc2013-evolution-d0eee4860651b7ce2e30f535372773a87db233c1.tar.zst gsoc2013-evolution-d0eee4860651b7ce2e30f535372773a87db233c1.zip |
Move this before the camel_vee_folder_remove_folder because that function
2001-07-05 Peter Williams <peterw@ximian.com>
* camel-vee-folder.c (camel_vee_folder_finalise): Move this before the
camel_vee_folder_remove_folder because that function modifies p->folders
messing up our iteration.
(camel_vee_folder_finalise): Don't unref our summary; camel-folder now
does this.
* camel-object.h (CamelObject): Add a 'destroying' flag to CamelObject.
* camel-object.c (obj_init): Clear 'destroying'.
(camel_object_unref): If 'destroying' then do not send the finalize
event and do not call finalize functions. Otherwise, set destroying
so just in case we get refed (eg event code) we don't get doubly
finalized.
svn path=/trunk/; revision=10811
Diffstat (limited to 'camel')
-rw-r--r-- | camel/ChangeLog | 16 | ||||
-rw-r--r-- | camel/camel-object.c | 37 | ||||
-rw-r--r-- | camel/camel-object.h | 5 | ||||
-rw-r--r-- | camel/camel-vee-folder.c | 4 |
4 files changed, 32 insertions, 30 deletions
diff --git a/camel/ChangeLog b/camel/ChangeLog index 793c515d1b..1a94bd7942 100644 --- a/camel/ChangeLog +++ b/camel/ChangeLog @@ -1,3 +1,19 @@ +2001-07-05 Peter Williams <peterw@ximian.com> + + * camel-vee-folder.c (camel_vee_folder_finalise): Move this before the + camel_vee_folder_remove_folder because that function modifies p->folders + messing up our iteration. + (camel_vee_folder_finalise): Don't unref our summary; camel-folder now + does this. + + * camel-object.h (CamelObject): Add a 'destroying' flag to CamelObject. + + * camel-object.c (obj_init): Clear 'destroying'. + (camel_object_unref): If 'destroying' then do not send the finalize + event and do not call finalize functions. Otherwise, set destroying + so just in case we get refed (eg event code) we don't get doubly + finalized. + 2001-07-05 Not Zed <NotZed@Ximian.com> * camel-mime-filter-basic.c (filter): Fix the assertion slightly, diff --git a/camel/camel-object.c b/camel/camel-object.c index a7c0e1b2f0..daa83284c0 100644 --- a/camel/camel-object.c +++ b/camel/camel-object.c @@ -324,6 +324,7 @@ obj_init (CamelObject * obj) obj->ref_count = 1; obj->event_to_hooklist = NULL; obj->in_event = 0; + obj->destroying = 0; } static void @@ -482,36 +483,20 @@ camel_object_unref (CamelObject * obj) G_UNLOCK (refcount); - /* Oh no! We want to emit a "finalized" event, but that function refs the object - * because it's not supposed to get finalized in an event, but it is being finalized - * right now, and AAUGH AAUGH AUGH AUGH! - * - * So we don't call camel_object_trigger_event. We do it ourselves. We even know - * that CamelObject doesn't provide a prep for the finalized event, so we plunge - * right in and call our hooks. - * - * And there was much rejoicing. + /* If the object already had its last unref, do not begin the + * destruction process again. This can happen if, for example, + * the object sends an event in its finalize handler (vfolders + * do this). */ -#define hooklist parents /*cough */ - - if (obj->event_to_hooklist) { - CamelHookPair *pair; - - hooklist = - g_hash_table_lookup (obj->event_to_hooklist, - "finalize"); - - while (hooklist && hooklist->data) { - pair = hooklist->data; - (pair->func) (obj, NULL, pair->user_data); - hooklist = hooklist->next; - } - } + if (obj->destroying) + return; + + obj->destroying = 1; - hooklist = NULL; /* Don't mess with this line */ + /* Send the finalize event */ -#undef hooklist + camel_object_trigger_event (obj, "finalize", NULL); /* Destroy it! hahaha! */ diff --git a/camel/camel-object.h b/camel/camel-object.h index f59ae5788d..484d414f10 100644 --- a/camel/camel-object.h +++ b/camel/camel-object.h @@ -81,10 +81,11 @@ CamelObjectClass; typedef struct _CamelObject { CamelObjectShared s; - guint32 ref_count:31; - guint32 in_event:1; CamelObjectClass *classfuncs; GHashTable *event_to_hooklist; + guint32 ref_count:30; + guint32 in_event:1; + guint32 destroying:1; } CamelObject; diff --git a/camel/camel-vee-folder.c b/camel/camel-vee-folder.c index 83a4bb4893..06cfaabbee 100644 --- a/camel/camel-vee-folder.c +++ b/camel/camel-vee-folder.c @@ -160,6 +160,8 @@ camel_vee_folder_finalise (CamelObject *obj) node = p->folders; while (node) { CamelFolder *f = node->data; + node = g_list_next(node); + if (vf != folder_unmatched) { camel_object_unhook_event((CamelObject *)f, "folder_changed", (CamelObjectEventHookFunc) folder_changed, vf); camel_object_unhook_event((CamelObject *)f, "message_changed", (CamelObjectEventHookFunc) message_changed, vf); @@ -168,7 +170,6 @@ camel_vee_folder_finalise (CamelObject *obj) camel_vee_folder_remove_folder(vf, f); } camel_object_unref((CamelObject *)f); - node = g_list_next(node); } g_free(vf->expression); @@ -176,7 +177,6 @@ camel_vee_folder_finalise (CamelObject *obj) camel_folder_change_info_free(vf->changes); camel_object_unref((CamelObject *)vf->search); - camel_object_unref((CamelObject *)((CamelFolder *)vf)->summary); #ifdef ENABLE_THREADS g_mutex_free(p->summary_lock); |