[gnome-boxes] get_screenshot() may be null, not get_display()



commit 9d1fee733edc00f67a1f8e3d1d747836508d925a
Author: Marc-Andrà Lureau <marcandre lureau gmail com>
Date:   Thu Nov 3 18:03:44 2011 +0100

    get_screenshot() may be null, not get_display()
    
    An invalid display will throw an exception,
    however, screenshots are not always available,
    and that's not an error.

 src/display.vala        |    4 ++--
 src/remote-machine.vala |    7 +++++--
 src/spice-display.vala  |    4 ++--
 src/vnc-display.vala    |    4 ++--
 4 files changed, 11 insertions(+), 8 deletions(-)
---
diff --git a/src/display.vala b/src/display.vala
index f57c873..1bfc0c6 100644
--- a/src/display.vala
+++ b/src/display.vala
@@ -19,8 +19,8 @@ private abstract class Boxes.Display: GLib.Object, Boxes.IProperties {
     public signal void hide (int display_id);
     public signal void disconnected ();
 
-    public abstract Gtk.Widget? get_display (int n) throws Boxes.Error;
-    public abstract Gdk.Pixbuf get_pixbuf (int n) throws Boxes.Error;
+    public abstract Gtk.Widget get_display (int n) throws Boxes.Error;
+    public abstract Gdk.Pixbuf? get_pixbuf (int n) throws Boxes.Error;
 
     public abstract void connect_it ();
     public abstract void disconnect_it ();
diff --git a/src/remote-machine.vala b/src/remote-machine.vala
index c6fea6b..fd7e49d 100644
--- a/src/remote-machine.vala
+++ b/src/remote-machine.vala
@@ -38,11 +38,14 @@ private class Boxes.RemoteMachine: Boxes.Machine, Boxes.IProperties {
         if (display != null) {
             try {
                 var pixbuf = display.get_pixbuf (0);
-                pixbuf.save (get_screenshot_filename (), "jpeg");
-                update_screenshot ();
+                if (pixbuf != null) {
+                    pixbuf.save (get_screenshot_filename (), "jpeg");
+                    update_screenshot ();
+                }
             } catch (GLib.Error err) {
                 warning (err.message);
             }
+
             display.disconnect_it ();
             display = null;
         }
diff --git a/src/spice-display.vala b/src/spice-display.vala
index 9362669..f858884 100644
--- a/src/spice-display.vala
+++ b/src/spice-display.vala
@@ -43,7 +43,7 @@ private class Boxes.SpiceDisplay: Boxes.Display, Boxes.IProperties {
         session.uri = uri;
     }
 
-    public override Gtk.Widget? get_display (int n) throws Boxes.Error {
+    public override Gtk.Widget get_display (int n) throws Boxes.Error {
         var display = displays.lookup (n) as Spice.Display;
 
         if (display == null) {
@@ -62,7 +62,7 @@ private class Boxes.SpiceDisplay: Boxes.Display, Boxes.IProperties {
         return display;
     }
 
-    public override Gdk.Pixbuf get_pixbuf (int n) throws Boxes.Error {
+    public override Gdk.Pixbuf? get_pixbuf (int n) throws Boxes.Error {
         return (get_display (n) as Spice.Display).get_pixbuf ();
     }
 
diff --git a/src/vnc-display.vala b/src/vnc-display.vala
index e8092b3..c1144b0 100644
--- a/src/vnc-display.vala
+++ b/src/vnc-display.vala
@@ -91,13 +91,13 @@ private class Boxes.VncDisplay: Boxes.Display {
         this.port = uri.port <= 0 ? 5900 : uri.port;
     }
 
-    public override Gtk.Widget? get_display (int n) throws Boxes.Error {
+    public override Gtk.Widget get_display (int n) throws Boxes.Error {
         window.remove (display);
 
         return display;
     }
 
-    public override Gdk.Pixbuf get_pixbuf (int n) throws Boxes.Error {
+    public override Gdk.Pixbuf? get_pixbuf (int n) throws Boxes.Error {
         return display.get_pixbuf ();
     }
 



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