[gnome-boxes/backport-to-the-future: 1/7] assistant, review-page: Do the cancellation of VM creation properly
- From: Felipe Borges <felipeborges src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-boxes/backport-to-the-future: 1/7] assistant, review-page: Do the cancellation of VM creation properly
- Date: Mon, 8 Jun 2020 10:59:22 +0000 (UTC)
commit 8bd1cbb7ecefba4ef683a6c997fdbae6072cb3ec
Author: Felipe Borges <felipeborges gnome org>
Date: Thu Jun 4 15:43:47 2020 +0200
assistant, review-page: Do the cancellation of VM creation properly
Boxes was failing at creating a VM when the user gave up on creating
a certain VM and instead decides to go back and create a new one
from another image/ISO.
The reason was that we were calling the cancellable.cancel
ourselves and never reseting the state of the GLib.Cancellable
object for the following VM creation attempt.
The proper handle of a GLib.Cancellable object is to drop the
reference right after cancelling and instantiating a brand new
GLib.Cancellable object for other operation. In other words, one
Cancellable per operation. I learned that the hard way. :)
src/assistant/review-page.vala | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
---
diff --git a/src/assistant/review-page.vala b/src/assistant/review-page.vala
index 953f4dcf..16326340 100644
--- a/src/assistant/review-page.vala
+++ b/src/assistant/review-page.vala
@@ -14,7 +14,7 @@
private Stack customization_stack;
private GLib.List<Boxes.Property> resource_properties;
- private Cancellable cancellable = new GLib.Cancellable ();
+ private Cancellable? cancellable;
[GtkCallback]
private void on_customize_button_toggled () {
@@ -23,7 +23,7 @@ private void on_customize_button_toggled () {
}
public async void setup (VMCreator vm_creator) {
- resource_properties = new GLib.List<Boxes.Property> ();
+ cancellable = new GLib.Cancellable ();
try {
artifact = yield vm_creator.create_vm (cancellable);
@@ -73,10 +73,14 @@ public async void populate (LibvirtMachine machine) {
}
private void populate_customization_grid (LibvirtMachine machine) {
+ resource_properties = new GLib.List<Boxes.Property> ();
machine.properties.get_resources_properties (ref resource_properties);
return_if_fail (resource_properties.length () > 0);
+ foreach (var child in customization_grid.get_children ())
+ customization_grid.remove (child);
+
var current_row = 0;
foreach (var property in resource_properties) {
if (property.widget == null || property.extra_widget == null) {
@@ -95,7 +99,10 @@ private void populate_customization_grid (LibvirtMachine machine) {
}
public override void cleanup () {
- cancellable.cancel ();
+ if (cancellable != null) {
+ cancellable.cancel ();
+ cancellable = null;
+ }
summary.clear ();
nokvm_infobar.hide ();
@@ -121,6 +128,7 @@ public override async void next () {
foreach (var property in resource_properties) {
property.flush ();
}
+ resource_properties = null;
done (artifact);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]