From ba5b1b6be7d3beed85c1f6b51d5808f9a7d72b5f Mon Sep 17 00:00:00 2001 From: 5 Date: Tue, 25 Sep 2001 22:18:52 +0000 Subject: Deal with destroy vs finalise semantics. Only destroy widgets here. 2001-09-25 * folder-browser.c (folder_browser_destroy): Deal with destroy vs finalise semantics. Only destroy widgets here. (folder_browser_finalise): object finalise function, actually unref/free all other objects here. (folder_browser_class_init): Init the finalise hook. (got_folder): Check if message_list == NULL -> we've been destroyed before the thread got a chance to finish loading the folder. (folder_browser_is_drafts): Dont use a g_return_if_fail to return in what could be a valid state of the object. (folder_browser_is_sent): Likewise. (folder_browser_copy): Do nothing if message_list == NULL. * main.c (main): call mail_msg_cleanup() before leaving threads. * component-factory.c (owner_unset_cb): Wait for all outstanding operations to finish before setting up to quit. (idle_quit): Wait for all outstanding ops to finish before cleanup. (unref_standard_folders): NULL out the standard folder before unreffing it. * mail-mt.c (mail_msg_wait_all): New function to wait for all outstanding thread operations. (mail_msg_cleanup): Destroy the io channels before we're finished. Also wait for all outstanding threads first. Made public. (mail_msg_init): Dont call mail_msg_cleanup atexit automatically. svn path=/trunk/; revision=13129 --- mail/mail-mt.c | 35 ++++++++++++++++++++++++++++++----- 1 file changed, 30 insertions(+), 5 deletions(-) (limited to 'mail/mail-mt.c') diff --git a/mail/mail-mt.c b/mail/mail-mt.c index 69646e44fd..2ce8f6cab4 100644 --- a/mail/mail-mt.c +++ b/mail/mail-mt.c @@ -260,6 +260,28 @@ void mail_msg_wait(unsigned int msgid) } } +void mail_msg_wait_all(void) +{ + struct _mail_msg *m; + int ismain = pthread_self() == mail_gui_thread; + + if (ismain) { + MAIL_MT_LOCK(mail_msg_lock); + while (g_hash_table_size(mail_msg_active) > 0) { + MAIL_MT_UNLOCK(mail_msg_lock); + gtk_main_iteration(); + MAIL_MT_LOCK(mail_msg_lock); + } + MAIL_MT_UNLOCK(mail_msg_lock); + } else { + MAIL_MT_LOCK(mail_msg_lock); + while (g_hash_table_size(mail_msg_active) > 0) { + pthread_cond_wait(&mail_msg_cond, &mail_msg_lock); + } + MAIL_MT_UNLOCK(mail_msg_lock); + } +} + EMsgPort *mail_gui_port; static GIOChannel *mail_gui_channel; EMsgPort *mail_gui_reply_port; @@ -366,16 +388,19 @@ mail_msg_received(EThread *e, EMsg *msg, void *data) } } -static void mail_msg_cleanup(void) +void mail_msg_cleanup(void) { + mail_msg_wait_all(); + e_thread_destroy(mail_thread_queued_slow); e_thread_destroy(mail_thread_queued); e_thread_destroy(mail_thread_new); + g_io_channel_unref(mail_gui_channel); + g_io_channel_unref(mail_gui_reply_channel); + e_msgport_destroy(mail_gui_port); e_msgport_destroy(mail_gui_reply_port); - - /* FIXME: channels too, etc */ } void mail_msg_init(void) @@ -406,8 +431,6 @@ void mail_msg_init(void) mail_msg_active = g_hash_table_new(NULL, NULL); mail_gui_thread = pthread_self(); - - atexit(mail_msg_cleanup); } /* ********************************************************************** */ @@ -450,6 +473,8 @@ pass_got (char *string, void *data) service = mca->transport; } + mail_config_service_set_save_passwd (service, remember); + if (mca) { mail_config_service_set_save_passwd (service, remember); -- cgit v1.2.3