[gnome-boxes] broker: add_source() should be able to fail



commit 7783fd209d013896393d68bd34f58f464b8e11ed
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date:   Tue Mar 15 19:27:13 2016 +0000

    broker: add_source() should be able to fail
    
    https://bugzilla.gnome.org/show_bug.cgi?id=760692

 src/app.vala            |   13 +++++++++----
 src/libvirt-broker.vala |    2 +-
 src/ovirt-broker.vala   |    2 +-
 3 files changed, 11 insertions(+), 6 deletions(-)
---
diff --git a/src/app.vala b/src/app.vala
index c4d7ffa..11998ce 100644
--- a/src/app.vala
+++ b/src/app.vala
@@ -2,7 +2,7 @@
 
 private abstract class Boxes.Broker : GLib.Object {
     // Overriding subclass should chain-up at the end of its implementation
-    public virtual async void add_source (CollectionSource source) {
+    public virtual async void add_source (CollectionSource source) throws GLib.Error {
         var used_configs = new GLib.List<BoxConfig> ();
         foreach (var item in App.app.collection.items.data) {
             if (!(item is Machine))
@@ -348,7 +348,7 @@ private class Boxes.App: Gtk.Application {
         collection.remove_item (machine);
     }
 
-    public async void add_collection_source (CollectionSource source) {
+    public async void add_collection_source (CollectionSource source) throws GLib.Error {
         if (!source.enabled)
             return;
 
@@ -456,8 +456,13 @@ private class Boxes.App: Gtk.Application {
             return false;
         });
 
-        foreach (var source in new_sources)
-            yield add_collection_source (source);
+        foreach (var source in new_sources) {
+            try {
+                yield add_collection_source (source);
+            } catch (GLib.Error error) {
+                warning ("Failed to add '%s': %s", source.name, error.message);
+            }
+        }
     }
 
     private void suspend_machines () {
diff --git a/src/libvirt-broker.vala b/src/libvirt-broker.vala
index 571e8c8..ad3fbb9 100644
--- a/src/libvirt-broker.vala
+++ b/src/libvirt-broker.vala
@@ -102,7 +102,7 @@ private class Boxes.LibvirtBroker : Boxes.Broker {
         }
     }
 
-    public override async void add_source (CollectionSource source) {
+    public override async void add_source (CollectionSource source) throws GLib.Error {
         if (connections.lookup (source.name) != null)
             return;
 
diff --git a/src/ovirt-broker.vala b/src/ovirt-broker.vala
index 10f5944..648ea30 100644
--- a/src/ovirt-broker.vala
+++ b/src/ovirt-broker.vala
@@ -25,7 +25,7 @@ private class Boxes.OvirtBroker : Boxes.Broker {
         }
     }
 
-    public override async void add_source (CollectionSource source) {
+    public override async void add_source (CollectionSource source) throws GLib.Error {
         if (proxies.lookup (source.name) != null)
             return;
 


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