[gnome-boxes] Ensure that you can only connect a Display once



commit 36589a3f18b07b43f26d52ab69a48c71682d5ab7
Author: Alexander Larsson <alexl redhat com>
Date:   Fri Sep 21 15:46:16 2012 +0200

    Ensure that you can only connect a Display once
    
    We currently handle reconnecting by creating a new Display object
    anyway. But we make Display.connect_it() callable multiple
    times (all but first are ignored) so that we can handle
    some activation races better.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=683042

 src/spice-display.vala |    6 ++++++
 src/vnc-display.vala   |    6 ++++++
 2 files changed, 12 insertions(+), 0 deletions(-)
---
diff --git a/src/spice-display.vala b/src/spice-display.vala
index 79eb115..e41ca63 100644
--- a/src/spice-display.vala
+++ b/src/spice-display.vala
@@ -13,6 +13,7 @@ private class Boxes.SpiceDisplay: Boxes.Display, Boxes.IPropertiesProvider {
     private ulong channel_destroy_id;
     private DisplayProperties.SavedProperty[] display_saved_properties;
     private DisplayProperties.SavedProperty[] gtk_session_saved_properties;
+    private bool connected;
 
     public bool resize_guest { get; set; }
     private void ui_state_changed () {
@@ -114,6 +115,11 @@ private class Boxes.SpiceDisplay: Boxes.Display, Boxes.IPropertiesProvider {
     }
 
     public override void connect_it () {
+        // We only initiate connection once
+        if (connected)
+            return;
+        connected = true;
+
         main_cleanup ();
 
         // FIXME: vala does't want to put this in ctor..
diff --git a/src/vnc-display.vala b/src/vnc-display.vala
index ec587f8..d8716a8 100644
--- a/src/vnc-display.vala
+++ b/src/vnc-display.vala
@@ -10,6 +10,7 @@ private class Boxes.VncDisplay: Boxes.Display {
     private int port;
     private Gtk.Window window;
     private DisplayProperties.SavedProperty[] saved_properties;
+    private bool connected;
 
     construct {
         saved_properties = {
@@ -112,6 +113,11 @@ private class Boxes.VncDisplay: Boxes.Display {
     }
 
     public override void connect_it () throws GLib.Error {
+        // We only initiate connection once
+        if (connected)
+            return;
+        connected = true;
+
         // FIXME: we ignore return value which seems to be inconsistent
         display.set_credential (DisplayCredential.USERNAME, username);
         display.set_credential (DisplayCredential.PASSWORD, password);



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