diff options
author | Milan Crha <mcrha@redhat.com> | 2012-01-02 21:33:06 +0800 |
---|---|---|
committer | Milan Crha <mcrha@redhat.com> | 2012-01-02 21:33:06 +0800 |
commit | 8aaf30553da0898104c9d6ef4c3ac935db7e0bce (patch) | |
tree | 8ee8cd10a7c16bf3b15629d6cfe12a0fd5307ce3 | |
parent | 1cc10110e59368929de65c131ed12d91e4c26c2c (diff) | |
download | gsoc2013-evolution-8aaf30553da0898104c9d6ef4c3ac935db7e0bce.tar.gz gsoc2013-evolution-8aaf30553da0898104c9d6ef4c3ac935db7e0bce.tar.zst gsoc2013-evolution-8aaf30553da0898104c9d6ef4c3ac935db7e0bce.zip |
Bug #641154 - Crash in emae_check_authtype_done
-rw-r--r-- | mail/em-account-editor.c | 40 |
1 files changed, 34 insertions, 6 deletions
diff --git a/mail/em-account-editor.c b/mail/em-account-editor.c index 3f8c1ae40f..32961f561c 100644 --- a/mail/em-account-editor.c +++ b/mail/em-account-editor.c @@ -238,6 +238,22 @@ static ServerData * emae_check_servers (const gchar *email); static gpointer parent_class; static void +emae_config_gone_cb (gpointer pemae, GObject *pconfig) +{ + EMAccountEditor *emae = pemae; + struct _EMConfig *config = (struct _EMConfig *) pconfig; + + if (!emae) + return; + + if (emae->config == config) + emae->config = NULL; + + if (emae->priv && emae->priv->config == config) + emae->priv->config = NULL; +} + +static void emae_set_original_account (EMAccountEditor *emae, EAccount *original_account) { @@ -387,6 +403,9 @@ emae_finalize (GObject *object) EMAccountEditor *emae = EM_ACCOUNT_EDITOR (object); EMAccountEditorPrivate *priv = emae->priv; + if (priv->config) + g_object_weak_unref ((GObject *) priv->config, emae_config_gone_cb, emae); + if (priv->sig_added_id) { ESignatureList *signatures; @@ -2029,7 +2048,9 @@ emae_check_authtype_done (CamelService *camel_service, auth_types = camel_service_query_auth_types_finish ( camel_service, result, &error); - editor = E_CONFIG (service->emae->config)->window; + editor = NULL; + if (service->emae && service->emae->config && E_IS_CONFIG (service->emae->config)) + editor = E_CONFIG (service->emae->config)->window; if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) { g_warn_if_fail (auth_types == NULL); @@ -2037,10 +2058,11 @@ emae_check_authtype_done (CamelService *camel_service, } else if (error != NULL) { g_warn_if_fail (auth_types == NULL); - e_alert_run_dialog_for_args ( - GTK_WINDOW (service->check_dialog), - "mail:checking-service-error", - error->message, NULL); + if (service->check_dialog) + e_alert_run_dialog_for_args ( + GTK_WINDOW (service->check_dialog), + "mail:checking-service-error", + error->message, NULL); g_error_free (error); } else { @@ -2049,7 +2071,10 @@ emae_check_authtype_done (CamelService *camel_service, emae_refresh_authtype (service->emae, service); } - gtk_widget_destroy (service->check_dialog); + if (service->check_dialog) { + g_object_weak_unref (G_OBJECT (service->check_dialog), (GWeakNotify) g_nullify_pointer, &service->check_dialog); + gtk_widget_destroy (service->check_dialog); + } service->check_dialog = NULL; if (editor != NULL) @@ -2136,6 +2161,7 @@ emae_check_authtype (GtkWidget *w, service->check_dialog = e_alert_dialog_new_for_args ( parent, "mail:checking-service", NULL); + g_object_weak_ref (G_OBJECT (service->check_dialog), (GWeakNotify) g_nullify_pointer, &service->check_dialog); g_object_ref (service->emae); @@ -4176,6 +4202,8 @@ em_account_editor_construct (EMAccountEditor *emae, ec, "commit", G_CALLBACK (emae_commit), emae); + g_object_weak_ref (G_OBJECT (ec), emae_config_gone_cb, emae); + emae->config = priv->config = ec; l = NULL; for (i = 0; items[i].path; i++) |