[gnome-boxes/gnome-3-4] Wait for libvirt setup before creating VMs



commit 56bd89489cbf855635b17af018fb958de336c9c7
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date:   Mon May 21 19:12:00 2012 +0300

    Wait for libvirt setup before creating VMs
    
    There is a possibility that we attempt to create VM before the async
    operation of creating libvirt connections is complete. When that
    happens, we end up making calls to null connection.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=676216

 src/vm-creator.vala |   13 ++++++++++++-
 1 files changed, 12 insertions(+), 1 deletions(-)
---
diff --git a/src/vm-creator.vala b/src/vm-creator.vala
index f3666a0..dfce0a5 100644
--- a/src/vm-creator.vala
+++ b/src/vm-creator.vala
@@ -5,7 +5,7 @@ using GVir;
 
 private class Boxes.VMCreator {
     private App app;
-    private Connection connection { get { return app.default_connection; } }
+    private Connection? connection { get { return app.default_connection; } }
     private VMConfigurator configurator;
     private ulong stopped_id;
 
@@ -43,6 +43,17 @@ private class Boxes.VMCreator {
     }
 
     public async void create_and_launch_vm (InstallerMedia install_media, Cancellable? cancellable) throws GLib.Error {
+        if (connection == null) {
+            // Wait for needed libvirt connection
+            ulong handler = 0;
+            handler = app.notify["default-connection"].connect (() => {
+                create_and_launch_vm.callback ();
+                app.disconnect (handler);
+            });
+
+            yield;
+        }
+
         var fullscreen = true;
         if (install_media is UnattendedInstaller) {
             var unattended = install_media as UnattendedInstaller;



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