aboutsummaryrefslogtreecommitdiffstats
path: root/camel/camel-object.c
diff options
context:
space:
mode:
authorPeter Williams <peterw@ximian.com>2001-07-06 00:40:45 +0800
committerPeter Williams <peterw@src.gnome.org>2001-07-06 00:40:45 +0800
commitd0eee4860651b7ce2e30f535372773a87db233c1 (patch)
treed9b9c45f96b8cc1bf255301c9005e0a2a6254fae /camel/camel-object.c
parentfb6a190f0085747e1146bc2f9153753fb95dd94b (diff)
downloadgsoc2013-evolution-d0eee4860651b7ce2e30f535372773a87db233c1.tar
gsoc2013-evolution-d0eee4860651b7ce2e30f535372773a87db233c1.tar.gz
gsoc2013-evolution-d0eee4860651b7ce2e30f535372773a87db233c1.tar.bz2
gsoc2013-evolution-d0eee4860651b7ce2e30f535372773a87db233c1.tar.lz
gsoc2013-evolution-d0eee4860651b7ce2e30f535372773a87db233c1.tar.xz
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/camel-object.c')
-rw-r--r--camel/camel-object.c37
1 files changed, 11 insertions, 26 deletions
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! */