[gnome-boxes] SpiceDisplay::get_display cannot throw
- From: Christophe Fergeau <teuf src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-boxes] SpiceDisplay::get_display cannot throw
- Date: Tue, 18 Sep 2012 11:03:52 +0000 (UTC)
commit 313c4824e076fbc9ea6bdee2e4f5b75f4ea50afd
Author: Christophe Fergeau <cfergeau redhat com>
Date: Tue Sep 18 11:21:22 2012 +0200
SpiceDisplay::get_display cannot throw
Spice::get_display() throws an exception when spice_display_new returns
null. However, this function is a wrapper over g_object_new so it cannot
return null. We can thus mark Spice::get_display() as not throwing, and
update its callers accordingly.
https://bugzilla.gnome.org/show_bug.cgi?id=684224
src/display.vala | 2 +-
src/machine.vala | 8 ++------
src/spice-display.vala | 38 +++++++++++++++-----------------------
src/vnc-display.vala | 2 +-
4 files changed, 19 insertions(+), 31 deletions(-)
---
diff --git a/src/display.vala b/src/display.vala
index d9a9436..a49f485 100644
--- a/src/display.vala
+++ b/src/display.vala
@@ -16,7 +16,7 @@ private abstract class Boxes.Display: Boxes.DisplayProperties, 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 Gtk.Widget get_display (int n);
public abstract Gdk.Pixbuf? get_pixbuf (int n) throws Boxes.Error;
public abstract void set_enable_inputs (Gtk.Widget widget, bool enable);
diff --git a/src/machine.vala b/src/machine.vala
index 4a7723b..c459159 100644
--- a/src/machine.vala
+++ b/src/machine.vala
@@ -55,12 +55,8 @@ private abstract class Boxes.Machine: Boxes.CollectionItem, Boxes.IPropertiesPro
private void show_display () {
Gtk.Widget widget;
- try {
- widget = display.get_display (0);
- } catch (Boxes.Error error) {
- warning (error.message);
- return;
- }
+
+ widget = display.get_display (0);
switch (App.app.ui_state) {
case Boxes.UIState.DISPLAY:
diff --git a/src/spice-display.vala b/src/spice-display.vala
index dbc8797..79eb115 100644
--- a/src/spice-display.vala
+++ b/src/spice-display.vala
@@ -17,14 +17,11 @@ private class Boxes.SpiceDisplay: Boxes.Display, Boxes.IPropertiesProvider {
public bool resize_guest { get; set; }
private void ui_state_changed () {
// TODO: multi display
- try {
- if (App.app.ui_state == UIState.PROPERTIES ||
- App.app.ui_state == UIState.DISPLAY) {
- // disable resize guest when minimizing guest widget
- var display = get_display (0) as Spice.Display;
- display.resize_guest = App.app.ui_state == UIState.DISPLAY ? resize_guest : false;
- }
- } catch (Boxes.Error error) {
+ if (App.app.ui_state == UIState.PROPERTIES ||
+ App.app.ui_state == UIState.DISPLAY) {
+ // disable resize guest when minimizing guest widget
+ var display = get_display (0) as Spice.Display;
+ display.resize_guest = App.app.ui_state == UIState.DISPLAY ? resize_guest : false;
}
}
@@ -83,15 +80,12 @@ private class Boxes.SpiceDisplay: Boxes.Display, Boxes.IPropertiesProvider {
session.uri = uri;
}
- public override Gtk.Widget get_display (int n) throws Boxes.Error {
+ public override Gtk.Widget get_display (int n) {
var display = displays.lookup (n) as Spice.Display;
if (display == null) {
display = new Spice.Display (session, n);
- if (display == null)
- throw new Boxes.Error.INVALID ("invalid display");
-
display.mouse_grab.connect((status) => {
mouse_grabbed = status != 0;
});
@@ -110,7 +104,7 @@ private class Boxes.SpiceDisplay: Boxes.Display, Boxes.IPropertiesProvider {
(widget as Spice.Display).disable_inputs = !enable;
}
- public override Gdk.Pixbuf? get_pixbuf (int n) throws Boxes.Error {
+ public override Gdk.Pixbuf? get_pixbuf (int n) {
var display = get_display (n) as Spice.Display;
if (!display.ready)
@@ -119,7 +113,7 @@ private class Boxes.SpiceDisplay: Boxes.Display, Boxes.IPropertiesProvider {
return display.get_pixbuf ();
}
- public override void connect_it () throws GLib.Error {
+ public override void connect_it () {
main_cleanup ();
// FIXME: vala does't want to put this in ctor..
@@ -141,15 +135,13 @@ private class Boxes.SpiceDisplay: Boxes.Display, Boxes.IPropertiesProvider {
return;
access_start ();
- try {
- var display = get_display (id) as Spice.Display;
- display.notify["ready"].connect (() => {
- if (display.ready)
- show (display.channel_id);
- else
- hide (display.channel_id);
- });
- } catch (Boxes.Error error) { warning (error.message); }
+ var display = get_display (id) as Spice.Display;
+ display.notify["ready"].connect (() => {
+ if (display.ready)
+ show (display.channel_id);
+ else
+ hide (display.channel_id);
+ });
}
});
diff --git a/src/vnc-display.vala b/src/vnc-display.vala
index 35b54de..ec587f8 100644
--- a/src/vnc-display.vala
+++ b/src/vnc-display.vala
@@ -97,7 +97,7 @@ 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) {
window.remove (display);
return display;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]