[gnome-boxes] Report errors in Machine::get_screenshot_filename()
- From: Christophe Fergeau <teuf src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-boxes] Report errors in Machine::get_screenshot_filename()
- Date: Thu, 13 Sep 2012 16:13:47 +0000 (UTC)
commit b04e43f298280e069900ec4478f18fc860ae41f0
Author: Christophe Fergeau <cfergeau redhat com>
Date: Tue Sep 11 12:38:42 2012 +0200
Report errors in Machine::get_screenshot_filename()
When the VM has just been created, config.uuid is not known yet.
When we quit Boxes from the wizard summary screen, the VM is deleted
when it's in such a state, which causes Criticals on the console when
it tries to delete the VM screenshot:
(gnome-boxes:5027): Boxes-CRITICAL **: boxes_get_screenshot_filename:
assertion `prefix != NULL' failed
This commit changes get_screenshot_filename() to report errors by
throwing a Boxes.Error exception and catches it in callers. This
removes the get_screenshot_filename() criticals in the scenario
described above.
https://bugzilla.gnome.org/show_bug.cgi?id=683792
src/machine.vala | 11 +++++++++--
1 files changed, 9 insertions(+), 2 deletions(-)
---
diff --git a/src/machine.vala b/src/machine.vala
index 871e66a..401b253 100644
--- a/src/machine.vala
+++ b/src/machine.vala
@@ -198,7 +198,10 @@ private abstract class Boxes.Machine: Boxes.CollectionItem, Boxes.IPropertiesPro
}
}
- private string get_screenshot_filename () {
+ private string get_screenshot_filename () throws Boxes.Error {
+ if (config.uuid == null)
+ throw new Boxes.Error.INVALID ("no uuid, cannot build screenshot filename");
+
return Boxes.get_screenshot_filename (config.uuid);
}
@@ -430,7 +433,11 @@ private abstract class Boxes.Machine: Boxes.CollectionItem, Boxes.IPropertiesPro
}
config.delete ();
- FileUtils.unlink (get_screenshot_filename ());
+ try {
+ FileUtils.unlink (get_screenshot_filename ());
+ } catch (Boxes.Error e) {
+ debug("Could not delete screenshot: %s", e.message);
+ }
}
public override void ui_state_changed () {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]