From 41c66f2d87932113de4cfb2a19a13daf67681297 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Fri, 7 Jan 2011 14:52:07 -0500 Subject: Avoid idle callbacks in EMailBackend initialization. If the migration phase has to show a dialog the idle callback for intializing mail stores will run too soon. Instead, hook it onto the EShellBackend start() method. Migration code can initialize mail stores early if it needs to. --- mail/e-mail-backend.c | 21 --------------------- mail/e-mail-migrate.c | 11 +++++++++-- mail/e-mail-store.c | 4 ++-- 3 files changed, 11 insertions(+), 25 deletions(-) (limited to 'mail') diff --git a/mail/e-mail-backend.c b/mail/e-mail-backend.c index 93262ec34c..740cf8526e 100644 --- a/mail/e-mail-backend.c +++ b/mail/e-mail-backend.c @@ -394,23 +394,6 @@ mail_backend_folder_changed_cb (MailFolderCache *folder_cache, (EEventTarget *) target); } -static gboolean -mail_backend_idle_cb (EMailBackend *backend) -{ - EMailSession *session; - EShellBackend *shell_backend; - const gchar *data_dir; - - session = e_mail_backend_get_session (backend); - - shell_backend = E_SHELL_BACKEND (backend); - data_dir = e_shell_backend_get_data_dir (shell_backend); - - e_mail_store_init (session, data_dir); - - return FALSE; -} - static void mail_backend_get_property (GObject *object, guint property_id, @@ -517,10 +500,6 @@ mail_backend_constructed (GObject *object) mail_config_init (priv->session); mail_msg_init (); - /* Defer initializing CamelStores until after the main loop - * has started, so migration has a chance to run first. */ - g_idle_add ((GSourceFunc) mail_backend_idle_cb, shell_backend); - if (G_OBJECT_CLASS (e_mail_backend_parent_class)->constructed) G_OBJECT_CLASS (e_mail_backend_parent_class)->constructed (object); } diff --git a/mail/e-mail-migrate.c b/mail/e-mail-migrate.c index 91a5e6fc43..ef12be0915 100644 --- a/mail/e-mail-migrate.c +++ b/mail/e-mail-migrate.c @@ -646,11 +646,14 @@ migrate_to_db (EShellBackend *shell_backend) mail_backend = E_MAIL_BACKEND (shell_backend); mail_session = e_mail_backend_get_session (mail_backend); + data_dir = e_shell_backend_get_data_dir (shell_backend); + + /* Initialize the mail stores early so we can add a new one. */ + e_mail_store_init (mail_session, data_dir); iter = e_list_get_iterator ((EList *) accounts); len = e_list_length ((EList *) accounts); - data_dir = e_shell_backend_get_data_dir (shell_backend); session = (EMMigrateSession *) em_migrate_session_new (data_dir); camel_session_set_online ((CamelSession *) session, FALSE); em_migrate_setup_progress_dialog ( @@ -965,10 +968,14 @@ create_mbox_account (EShellBackend *shell_backend, EMMigrateSession *session) mail_backend = E_MAIL_BACKEND (shell_backend); mail_session = e_mail_backend_get_session (mail_backend); + data_dir = e_shell_backend_get_data_dir (shell_backend); + + /* Initialize the mail stores early so we can add a new one. */ + e_mail_store_init (mail_session, data_dir); + account = e_account_new (); account->enabled = TRUE; - data_dir = e_shell_backend_get_data_dir (shell_backend); url = camel_url_new ("mbox:", NULL); temp = g_build_filename (data_dir, "local_mbox", NULL); camel_url_set_path (url, temp); diff --git a/mail/e-mail-store.c b/mail/e-mail-store.c index ac0e97562b..1e4155bf6e 100644 --- a/mail/e-mail-store.c +++ b/mail/e-mail-store.c @@ -268,8 +268,8 @@ e_mail_store_init (EMailSession *session, g_return_if_fail (E_IS_MAIL_SESSION (session)); - /* This function is idempotent, but there should - * be no need to call it more than once. */ + /* This function is idempotent because mail + * migration code may need to call it early. */ if (initialized) return; -- cgit v1.2.3