summaryrefslogtreecommitdiffstats
path: root/src/virt-viewer-display-spice.c
diff options
context:
space:
mode:
authorMarc-André Lureau <marcandre.lureau@gmail.com>2012-07-17 16:39:49 +0200
committerMarc-André Lureau <marcandre.lureau@gmail.com>2012-07-23 16:27:33 +0200
commit57bf1e9090dbd6ca0f3486763ba9284a710883ef (patch)
treef0c92f7f6c8a36cf9d90ebad8776466b27ea0cc6 /src/virt-viewer-display-spice.c
parent6f9c7a624e406cf1b9e89da558937e6d91b4daa4 (diff)
downloadvirt-viewer-57bf1e9090dbd6ca0f3486763ba9284a710883ef.tar.gz
virt-viewer-57bf1e9090dbd6ca0f3486763ba9284a710883ef.tar.xz
virt-viewer-57bf1e9090dbd6ca0f3486763ba9284a710883ef.zip
spice: factor out main channel lookup code
Diffstat (limited to 'src/virt-viewer-display-spice.c')
-rw-r--r--src/virt-viewer-display-spice.c22
1 files changed, 17 insertions, 5 deletions
diff --git a/src/virt-viewer-display-spice.c b/src/virt-viewer-display-spice.c
index 81eb16f..b2f7e6c 100644
--- a/src/virt-viewer-display-spice.c
+++ b/src/virt-viewer-display-spice.c
@@ -76,14 +76,27 @@ virt_viewer_display_spice_class_init(VirtViewerDisplaySpiceClass *klass)
g_type_class_add_private(klass, sizeof(VirtViewerDisplaySpicePrivate));
}
+static SpiceMainChannel*
+get_main(VirtViewerDisplay *self)
+{
+ VirtViewerSessionSpice *session;
+
+ session = VIRT_VIEWER_SESSION_SPICE(virt_viewer_display_get_session(self));
+
+ return virt_viewer_session_spice_get_main_channel(session);
+}
+
static void
show_hint_changed(VirtViewerDisplay *self)
{
- SpiceMainChannel *main_channel = virt_viewer_session_spice_get_main_channel(
- VIRT_VIEWER_SESSION_SPICE(virt_viewer_display_get_session(self)));
+ SpiceMainChannel *main_channel = get_main(self);
guint enabled = TRUE;
guint nth;
+ /* this may happen when finalizing */
+ if (!main_channel)
+ return;
+
g_object_get(self, "nth-display", &nth, NULL);
if (virt_viewer_display_get_show_hint(self) & VIRT_VIEWER_DISPLAY_SHOW_HINT_DISABLED)
enabled = FALSE;
@@ -191,9 +204,8 @@ virt_viewer_display_spice_size_allocate(VirtViewerDisplaySpice *self,
g_object_get(self, "nth-display", &nth, NULL);
- SpiceMainChannel *main_channel = virt_viewer_session_spice_get_main_channel(
- VIRT_VIEWER_SESSION_SPICE(virt_viewer_display_get_session(VIRT_VIEWER_DISPLAY(self))));
- spice_main_set_display(main_channel, nth, 0, 0, dw, dh);
+ spice_main_set_display(get_main(VIRT_VIEWER_DISPLAY(self)),
+ nth, 0, 0, dw, dh);
}
static void