From 6e163b39c75dbba470d073b4f79a897aa6fb0e54 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Tue, 24 Mar 2009 02:05:26 +0000 Subject: Saving progress again on the attachment rewrite. svn path=/branches/kill-bonobo/; revision=37470 --- widgets/misc/e-activity.c | 36 ++++++++++++++++++++++++++++++------ 1 file changed, 30 insertions(+), 6 deletions(-) (limited to 'widgets/misc/e-activity.c') diff --git a/widgets/misc/e-activity.c b/widgets/misc/e-activity.c index c65c3aaa0a..d40d5aacbe 100644 --- a/widgets/misc/e-activity.c +++ b/widgets/misc/e-activity.c @@ -69,6 +69,7 @@ activity_idle_cancel_cb (EActivity *activity) { activity->priv->idle_id = 0; e_activity_cancel (activity); + g_object_unref (activity); return FALSE; } @@ -78,6 +79,7 @@ activity_idle_complete_cb (EActivity *activity) { activity->priv->idle_id = 0; e_activity_complete (activity); + g_object_unref (activity); return FALSE; } @@ -474,13 +476,24 @@ e_activity_cancel (EActivity *activity) void e_activity_cancel_in_idle (EActivity *activity) { + guint old_idle_id; + g_return_if_fail (E_IS_ACTIVITY (activity)); - if (activity->priv->idle_id > 0) - g_source_remove (activity->priv->idle_id); + /* Be careful not to finalize the activity. Decrement the + * reference count only after incrementing it, in case this + * is the last reference. */ + + old_idle_id = activity->priv->idle_id; activity->priv->idle_id = g_idle_add ( - (GSourceFunc) activity_idle_cancel_cb, activity); + (GSourceFunc) activity_idle_cancel_cb, + g_object_ref (activity)); + + if (old_idle_id > 0) { + g_source_remove (old_idle_id); + g_object_unref (activity); + } } void @@ -500,13 +513,24 @@ e_activity_complete (EActivity *activity) void e_activity_complete_in_idle (EActivity *activity) { + guint old_idle_id; + g_return_if_fail (E_IS_ACTIVITY (activity)); - if (activity->priv->idle_id > 0) - g_source_remove (activity->priv->idle_id); + /* Be careful not to finalize the activity. Decrement the + * reference count only after incrementing it, in case this + * is the last reference. */ + + old_idle_id = activity->priv->idle_id; activity->priv->idle_id = g_idle_add ( - (GSourceFunc) activity_idle_complete_cb, activity); + (GSourceFunc) activity_idle_complete_cb, + g_object_ref (activity)); + + if (old_idle_id > 0) { + g_source_remove (old_idle_id); + g_object_unref (activity); + } } void -- cgit v1.2.3