From 6f014d4779a7bf13d39cdc6eea153cb40dba1b24 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Thu, 24 Jun 2010 11:12:53 -0400 Subject: Bug 622547 - mail_async_event_destroy() doesn't cancel its idle callback --- mail/mail-mt.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'mail/mail-mt.c') diff --git a/mail/mail-mt.c b/mail/mail-mt.c index de59213ce5..76a6ccc488 100644 --- a/mail/mail-mt.c +++ b/mail/mail-mt.c @@ -605,6 +605,7 @@ struct _proxy_msg { mail_async_event_t type; GThread *thread; + guint idle_id; MailAsyncFunc func; gpointer o; @@ -625,10 +626,11 @@ do_async_event(struct _proxy_msg *m) } static gint -idle_async_event(gpointer mm) +idle_async_event (struct _proxy_msg *m) { - do_async_event(mm); - mail_msg_unref(mm); + m->idle_id = 0; + do_async_event (m); + mail_msg_unref (m); return FALSE; } @@ -652,7 +654,7 @@ mail_async_event_new (void) return ea; } -gint +guint mail_async_event_emit (MailAsyncEvent *ea, mail_async_event_t type, MailAsyncFunc func, @@ -661,7 +663,7 @@ mail_async_event_emit (MailAsyncEvent *ea, gpointer data) { struct _proxy_msg *m; - gint id; + guint id; /* We dont have a reply port for this, we dont * care when/if it gets executed, just queue it. */ @@ -684,7 +686,8 @@ mail_async_event_emit (MailAsyncEvent *ea, * overflow and deadlock us. */ if (type == MAIL_ASYNC_GUI) { if (mail_in_main_thread ()) - g_idle_add(idle_async_event, m); + m->idle_id = g_idle_add ( + (GSourceFunc) idle_async_event, m); else mail_msg_main_loop_push(m); } else @@ -709,6 +712,10 @@ mail_async_event_destroy (MailAsyncEvent *ea) errno = EDEADLK; return -1; } + if (m->idle_id > 0) { + g_source_remove (m->idle_id); + m->idle_id = 0; + } g_mutex_unlock(ea->lock); mail_msg_wait(id); g_mutex_lock(ea->lock); -- cgit