[gnome-boxes] Turn LibvirtMachine.state from property to a method



commit 65728019d5c4256ae13b43a0ce8a98d1348f6063
Author: Alexander Larsson <alexl redhat com>
Date:   Mon May 7 15:49:51 2012 +0200

    Turn LibvirtMachine.state from property to a method
    
    This was getting called in multiple places as if it was a cheap method, while
    in reality its a blocking rpc call. Sometimes it was even used multiple times
    within a method.
    
    The new method is called get_state_sync() to make it obvious that this is a
    blocking call.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=675663

 src/libvirt-machine.vala |   16 ++++++++--------
 1 files changed, 8 insertions(+), 8 deletions(-)
---
diff --git a/src/libvirt-machine.vala b/src/libvirt-machine.vala
index 81806c5..4b980d0 100644
--- a/src/libvirt-machine.vala
+++ b/src/libvirt-machine.vala
@@ -6,13 +6,12 @@ private class Boxes.LibvirtMachine: Boxes.Machine {
     public GVir.Domain domain;
     public GVirConfig.Domain domain_config;
     public GVir.Connection connection;
-    public DomainState state {
-        get {
-            try {
-                return domain.get_info ().state;
-            } catch (GLib.Error error) {
-                return DomainState.NONE;
-            }
+
+    private DomainState get_state_sync () {
+        try {
+            return domain.get_info ().state;
+        } catch (GLib.Error error) {
+            return DomainState.NONE;
         }
     }
 
@@ -35,6 +34,7 @@ private class Boxes.LibvirtMachine: Boxes.Machine {
         if (display != null)
             return;
 
+        var state = get_state_sync ();
         if (state != DomainState.RUNNING) {
             if (started_id != 0)
                 return;
@@ -314,7 +314,7 @@ private class Boxes.LibvirtMachine: Boxes.Machine {
     }
 
     public override bool is_running () {
-        return state == DomainState.RUNNING;
+        return get_state_sync () == DomainState.RUNNING;
     }
 
     public override async bool take_screenshot () throws GLib.Error {



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