[gnome-boxes] Allow LibvirtMachine::start to throw exceptions



commit 7aeeb81efcda213081464398a3e738c791e439a6
Author: Christophe Fergeau <cfergeau redhat com>
Date:   Mon Sep 17 14:58:30 2012 +0200

    Allow LibvirtMachine::start to throw exceptions
    
    It's only used in two places, once in connect_display() where we
    want to get an exception when something happens, and once in
    notify_reboot_required() where only .begin() is called, so this does
    not change behaviour as the exception would be reported when calling
    .end()
    
    https://bugzilla.gnome.org/show_bug.cgi?id=684224

 src/libvirt-machine.vala |   35 +++++++++++++++++++----------------
 1 files changed, 19 insertions(+), 16 deletions(-)
---
diff --git a/src/libvirt-machine.vala b/src/libvirt-machine.vala
index 3dad11e..d7bd089 100644
--- a/src/libvirt-machine.vala
+++ b/src/libvirt-machine.vala
@@ -555,27 +555,24 @@ private class Boxes.LibvirtMachine: Boxes.Machine {
         };
     }
 
-    private async void start () {
+    private async void start () throws GLib.Error {
         if (state == MachineState.RUNNING)
             return;
 
-        try {
-            if (state == MachineState.PAUSED)
-                yield domain.resume_async (null);
-            else {
-                if (domain.get_saved ())
-                    // Translators: The %s will be expanded with the name of the vm
-                    status = _("Restoring %s from disk").printf (name);
-                else
-                    // Translators: The %s will be expanded with the name of the vm
-                    status = _("Starting %s").printf (name);
-                yield domain.start_async (0, null);
-            }
-        } catch (GLib.Error error) {
-            warning ("Failed to start '%s': %s", domain.get_name (), error.message);
+        if (state == MachineState.PAUSED)
+            yield domain.resume_async (null);
+        else {
+            if (domain.get_saved ())
+                // Translators: The %s will be expanded with the name of the vm
+                status = _("Restoring %s from disk").printf (name);
+            else
+                // Translators: The %s will be expanded with the name of the vm
+                status = _("Starting %s").printf (name);
+            yield domain.start_async (0, null);
         }
     }
 
+
     private void notify_reboot_required () {
         Notificationbar.OKFunc reboot = () => {
             debug ("Rebooting '%s'..", name);
@@ -583,7 +580,13 @@ private class Boxes.LibvirtMachine: Boxes.Machine {
             ulong state_id = 0;
             state_id = this.notify["state"].connect (() => {
                 if (state == MachineState.STOPPED) {
-                    start.begin ();
+                    start.begin ((obj, res) => {
+                        try {
+                            start.end (res);
+                        } catch (GLib.Error error) {
+                            warning ("Failed to start '%s': %s", domain.get_name (), error.message);
+                        }
+                    });
                     this.disconnect (state_id);
                 }
             });



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]