[gnome-boxes] Allow deleting inactive libvirt boxes



commit 3485496bd3aaf66a957aa788ed3d27745bbc7ffd
Author: Marc-Andrà Lureau <marcandre lureau gmail com>
Date:   Tue Nov 22 14:54:35 2011 +0100

    Allow deleting inactive libvirt boxes
    
    And fix related deletion warnings
    
    https://bugzilla.gnome.org/show_bug.cgi?id=664561

 src/collection-view.vala |    5 ++++-
 src/libvirt-machine.vala |   14 +++++++++++++-
 2 files changed, 17 insertions(+), 2 deletions(-)
---
diff --git a/src/collection-view.vala b/src/collection-view.vala
index 1729e70..b19c52f 100644
--- a/src/collection-view.vala
+++ b/src/collection-view.vala
@@ -169,7 +169,10 @@ private class Boxes.CollectionView: Boxes.UI {
         var iter = item.get_data<Gtk.TreeIter?> ("iter");
         var pixbuf_id = item.get_data<ulong> ("pixbuf_id");
 
-        return_if_fail (iter != null);
+        if (iter == null) {
+            debug ("item not in view or already removed");
+            return;
+        }
 
         model.remove (iter);
         item.set_data<Gtk.TreeIter?> ("iter", null);
diff --git a/src/libvirt-machine.vala b/src/libvirt-machine.vala
index dfac8a2..e5e011c 100644
--- a/src/libvirt-machine.vala
+++ b/src/libvirt-machine.vala
@@ -84,6 +84,10 @@ private class Boxes.LibvirtMachine: Boxes.Machine {
         stats = new MachineStat[STATS_SIZE];
     }
 
+    ~LibvirtMachine () {
+        set_stats_enable (false);
+    }
+
     public LibvirtMachine (CollectionSource source, Boxes.App app,
                            GVir.Connection connection, GVir.Domain domain) {
         base (source, app, domain.get_name ());
@@ -315,10 +319,18 @@ private class Boxes.LibvirtMachine: Boxes.Machine {
 
     public override void delete () {
         try {
-            domain.stop (0);
+            if (is_running ())
+                domain.stop (0);
+        } catch (GLib.Error err) {
+            // ignore stop error
+        }
+
+        try {
             domain.delete (0);
         } catch (GLib.Error err) {
             warning (err.message);
         }
+
+        set_stats_enable (false);
     }
 }



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