app-chooser-dialog: cancel the PK operation when the dialog is dismissed

This doesn't really seem to have any effect; probably PK doesn't listen
for changes on the passed-in cancellable, but it's correct.

Related to: https://bugzilla.gnome.org/show_bug.cgi?id=649121
This commit is contained in:
Cosimo Cecchi 2012-02-01 13:19:52 -05:00
parent 623b5192cc
commit 2ae2c443d0
2 changed files with 14 additions and 6 deletions

View File

@ -146,6 +146,7 @@ search_for_mimetype_ready_cb (GObject *source,
} }
out: out:
g_clear_object (&self->priv->online_cancellable);
g_clear_error (&error); g_clear_error (&error);
g_object_unref (self); g_object_unref (self);
@ -296,6 +297,16 @@ add_or_find_application (GtkAppChooserDialog *self)
} }
} }
static void
cancel_and_clear_cancellable (GtkAppChooserDialog *self)
{
if (self->priv->online_cancellable != NULL)
{
g_cancellable_cancel (self->priv->online_cancellable);
g_clear_object (&self->priv->online_cancellable);
}
}
static void static void
gtk_app_chooser_dialog_response (GtkDialog *dialog, gtk_app_chooser_dialog_response (GtkDialog *dialog,
gint response_id, gint response_id,
@ -310,6 +321,7 @@ gtk_app_chooser_dialog_response (GtkDialog *dialog,
break; break;
case GTK_RESPONSE_CANCEL: case GTK_RESPONSE_CANCEL:
case GTK_RESPONSE_DELETE_EVENT: case GTK_RESPONSE_DELETE_EVENT:
cancel_and_clear_cancellable (self);
self->priv->dismissed = TRUE; self->priv->dismissed = TRUE;
default : default :
break; break;
@ -631,14 +643,9 @@ gtk_app_chooser_dialog_dispose (GObject *object)
GtkAppChooserDialog *self = GTK_APP_CHOOSER_DIALOG (object); GtkAppChooserDialog *self = GTK_APP_CHOOSER_DIALOG (object);
g_clear_object (&self->priv->gfile); g_clear_object (&self->priv->gfile);
cancel_and_clear_cancellable (self);
g_clear_object (&self->priv->online); g_clear_object (&self->priv->online);
if (self->priv->online_cancellable != NULL)
{
g_cancellable_cancel (self->priv->online_cancellable);
g_clear_object (&self->priv->online_cancellable);
}
G_OBJECT_CLASS (gtk_app_chooser_dialog_parent_class)->dispose (object); G_OBJECT_CLASS (gtk_app_chooser_dialog_parent_class)->dispose (object);
} }

View File

@ -118,6 +118,7 @@ install_mime_types_ready_cb (GObject *source,
} }
g_simple_async_result_complete (self->priv->result); g_simple_async_result_complete (self->priv->result);
g_clear_object (&self->priv->result);
} }
static void static void