[gnome-boxes/gnome-3-14] wizard: Instantiate prepare_cancellable only once
- From: Zeeshan Ali Khattak <zeeshanak src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-boxes/gnome-3-14] wizard: Instantiate prepare_cancellable only once
- Date: Mon, 27 Oct 2014 19:12:05 +0000 (UTC)
commit 7c7b56d32d78b8a2c716c5b0c552d3486968a87c
Author: Lasse Schuirmann <lasse schuirmann gmail com>
Date: Sun Oct 19 13:08:59 2014 +0200
wizard: Instantiate prepare_cancellable only once
It is useless to reinstantiate it several times. This also lowers
code complexity a bit.
https://bugzilla.gnome.org/show_bug.cgi?id=725386
src/wizard.vala | 13 +++++--------
1 files changed, 5 insertions(+), 8 deletions(-)
---
diff --git a/src/wizard.vala b/src/wizard.vala
index 00d5581..5b879cf 100644
--- a/src/wizard.vala
+++ b/src/wizard.vala
@@ -53,7 +53,7 @@ private class Boxes.Wizard: Gtk.Stack, Boxes.UI {
protected Machine? machine { get; set; }
private LibvirtMachine? libvirt_machine { get { return (machine as LibvirtMachine); } }
- private Cancellable? prepare_cancellable;
+ private Cancellable prepare_cancellable = new Cancellable ();
private Cancellable? review_cancellable;
private bool skip_review_for_live;
@@ -209,8 +209,7 @@ private class Boxes.Wizard: Gtk.Stack, Boxes.UI {
}
public void cleanup () {
- if (prepare_cancellable != null)
- prepare_cancellable.cancel ();
+ prepare_cancellable.cancel ();
destroy_machine ();
vm_creator = null;
@@ -361,7 +360,8 @@ private class Boxes.Wizard: Gtk.Stack, Boxes.UI {
return false;
}
- prepare_cancellable = new Cancellable ();
+ prepare_cancellable.reset ();
+
if (wizard_source.download_required) {
continue_button.sensitive = false;
download_media.begin (wizard_source.uri, progress);
@@ -588,8 +588,6 @@ private class Boxes.Wizard: Gtk.Stack, Boxes.UI {
warning ("Failed downloading media '%s'! %s", uri, e.message);
window.notificationbar.display_error (_("Download failed."));
page = WizardPage.SOURCE;
- } finally {
- prepare_cancellable = null;
}
}
@@ -612,8 +610,7 @@ private class Boxes.Wizard: Gtk.Stack, Boxes.UI {
});
back_button = window.topbar.wizard_toolbar.back_btn;
back_button.clicked.connect (() => {
- if (prepare_cancellable != null)
- prepare_cancellable.cancel ();
+ prepare_cancellable.cancel ();
page = page - 1;
});
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]