[gnome-online-accounts/wip/rishi/owncloud-gssapi: 8/9] owncloud: Consolidate the different ways in which we run the dialog
- From: Debarshi Ray <debarshir src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-online-accounts/wip/rishi/owncloud-gssapi: 8/9] owncloud: Consolidate the different ways in which we run the dialog
- Date: Tue, 26 Apr 2016 16:52:30 +0000 (UTC)
commit 99aae6abfe59709457fdac47cd406e3602a720c4
Author: Debarshi Ray <debarshir gnome org>
Date: Sat Feb 20 20:23:48 2016 +0100
owncloud: Consolidate the different ways in which we run the dialog
Let's stick to gtk_dialog_run, instead of a mix of gtk_dialog_run and
a hand rolled GMainLoop. Keep in mind that during cancellation the
order of events is:
- GtkDialog::response handler is called
- gtk_dialog_run returns
- Callback of any in-flight asynchronous operation that was cancelled
by the GtkDialog::response handler
Therefore, the goa_http_client_check callback should not touch
AddAccountData if G_IO_ERROR_CANCELLED was thrown, because it would
have been destroyed before the callback was called.
https://bugzilla.gnome.org/show_bug.cgi?id=762097
src/goabackend/goaowncloudprovider.c | 44 ++++++++++++++++++++--------------
1 files changed, 26 insertions(+), 18 deletions(-)
---
diff --git a/src/goabackend/goaowncloudprovider.c b/src/goabackend/goaowncloudprovider.c
index 0bfb96f..2543187 100644
--- a/src/goabackend/goaowncloudprovider.c
+++ b/src/goabackend/goaowncloudprovider.c
@@ -625,11 +625,23 @@ check_cb (GObject *source_object, GAsyncResult *res, gpointer user_data)
{
GoaHttpClient *client = GOA_HTTP_CLIENT (source_object);
AddAccountData *data = user_data;
+ GError *error;
+
+ error = NULL;
+ if (!goa_http_client_check_finish (client, res, &error))
+ {
+ if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
+ {
+ g_error_free (error);
+ return;
+ }
+
+ g_propagate_error (&data->error, error);
+ }
- goa_http_client_check_finish (client, res, &data->error);
- g_main_loop_quit (data->loop);
gtk_widget_set_sensitive (data->connect_button, TRUE);
show_progress_ui (GTK_CONTAINER (data->progress_grid), FALSE);
+ gtk_dialog_response (data->dialog, GTK_RESPONSE_OK);
}
static void
@@ -729,16 +741,14 @@ add_account (GoaProvider *provider,
gtk_widget_set_sensitive (data.connect_button, FALSE);
show_progress_ui (GTK_CONTAINER (data.progress_grid), TRUE);
- g_main_loop_run (data.loop);
- if (g_cancellable_is_cancelled (data.check_cancellable))
+ response = gtk_dialog_run (dialog);
+ if (response != GTK_RESPONSE_OK)
{
- g_prefix_error (&data.error,
- _("Dialog was dismissed (%s, %d): "),
- g_quark_to_string (data.error->domain),
- data.error->code);
- data.error->domain = GOA_ERROR;
- data.error->code = GOA_ERROR_DIALOG_DISMISSED;
+ g_set_error (&data.error,
+ GOA_ERROR,
+ GOA_ERROR_DIALOG_DISMISSED,
+ _("Dialog was dismissed"));
goto out;
}
else if (data.error != NULL)
@@ -921,16 +931,14 @@ refresh_account (GoaProvider *provider,
&data);
gtk_widget_set_sensitive (data.connect_button, FALSE);
show_progress_ui (GTK_CONTAINER (data.progress_grid), TRUE);
- g_main_loop_run (data.loop);
- if (g_cancellable_is_cancelled (data.check_cancellable))
+ response = gtk_dialog_run (GTK_DIALOG (dialog));
+ if (response != GTK_RESPONSE_OK)
{
- g_prefix_error (&data.error,
- _("Dialog was dismissed (%s, %d): "),
- g_quark_to_string (data.error->domain),
- data.error->code);
- data.error->domain = GOA_ERROR;
- data.error->code = GOA_ERROR_DIALOG_DISMISSED;
+ g_set_error (&data.error,
+ GOA_ERROR,
+ GOA_ERROR_DIALOG_DISMISSED,
+ _("Dialog was dismissed"));
goto out;
}
else if (data.error != NULL)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]