[gnome-boxes/gnome-3-4] Init Machine.state in constructor, not later



commit 641a31d4dfa0d277f7d272752e33e36412bb14e3
Author: Alexander Larsson <alexl redhat com>
Date:   Wed May 9 14:41:53 2012 +0200

    Init Machine.state in constructor, not later
    
    We need this early on to see whether to show the screenshot as running or not on startup.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=675663

 src/libvirt-machine.vala |   58 +++++++++++++++++++++++-----------------------
 1 files changed, 29 insertions(+), 29 deletions(-)
---
diff --git a/src/libvirt-machine.vala b/src/libvirt-machine.vala
index 58d4930..9f991ec 100644
--- a/src/libvirt-machine.vala
+++ b/src/libvirt-machine.vala
@@ -27,35 +27,6 @@ private class Boxes.LibvirtMachine: Boxes.Machine {
         if (display != null)
             return;
 
-        try {
-            var s = domain.get_info ().state;
-            switch (s) {
-            case DomainState.RUNNING:
-            case DomainState.BLOCKED:
-                state = MachineState.RUNNING;
-                break;
-            case DomainState.PAUSED:
-                state = MachineState.PAUSED;
-                break;
-            case DomainState.SHUTDOWN:
-            case DomainState.SHUTOFF:
-            case DomainState.CRASHED:
-                state = MachineState.STOPPED;
-                break;
-            default:
-            case DomainState.NONE:
-                state = MachineState.UNKNOWN;
-                break;
-            }
-        } catch (GLib.Error error) {
-            state = MachineState.UNKNOWN;
-        }
-
-        domain.started.connect (() => { state = MachineState.RUNNING; });
-        domain.suspended.connect (() => { state = MachineState.PAUSED; });
-        domain.resumed.connect (() => { state = MachineState.RUNNING; });
-        domain.stopped.connect (() => { state = MachineState.STOPPED; });
-
         if (state != MachineState.RUNNING) {
             if (started_id != 0)
                 return;
@@ -136,6 +107,35 @@ private class Boxes.LibvirtMachine: Boxes.Machine {
         this.connection = connection;
         this.domain = domain;
 
+        try {
+            var s = domain.get_info ().state;
+            switch (s) {
+            case DomainState.RUNNING:
+            case DomainState.BLOCKED:
+                state = MachineState.RUNNING;
+                break;
+            case DomainState.PAUSED:
+                state = MachineState.PAUSED;
+                break;
+            case DomainState.SHUTDOWN:
+            case DomainState.SHUTOFF:
+            case DomainState.CRASHED:
+                state = MachineState.STOPPED;
+                break;
+            default:
+            case DomainState.NONE:
+                state = MachineState.UNKNOWN;
+                break;
+            }
+        } catch (GLib.Error error) {
+            state = MachineState.UNKNOWN;
+        }
+
+        domain.started.connect (() => { state = MachineState.RUNNING; });
+        domain.suspended.connect (() => { state = MachineState.PAUSED; });
+        domain.resumed.connect (() => { state = MachineState.RUNNING; });
+        domain.stopped.connect (() => { state = MachineState.STOPPED; });
+
         update_domain_config ();
         domain.updated.connect (update_domain_config);
 



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