[Spice-devel] [PATCH v3 4/9] display: return NULL in spice_display_get_gl_scanout()
Marc-André Lureau
marcandre.lureau at gmail.com
Thu Mar 24 11:32:38 UTC 2016
If there is no valid scanout, return NULL.
Signed-off-by: Marc-André Lureau <marcandre.lureau at gmail.com>
Acked-by: Pavel Grunt <pgrunt at redhat.com>
---
src/channel-display.c | 4 ++--
src/spice-widget.c | 1 +
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/src/channel-display.c b/src/channel-display.c
index 2c54df7..90d155e 100644
--- a/src/channel-display.c
+++ b/src/channel-display.c
@@ -532,7 +532,7 @@ void spice_display_change_preferred_compression(SpiceChannel *channel, gint comp
* spice_display_get_gl_scanout:
* @channel: a #SpiceDisplayChannel
*
- * Returns: the current GL scanout
+ * Returns: the current GL scanout, or %NULL if none or not valid
*
* Since: 0.31
**/
@@ -541,7 +541,7 @@ spice_display_get_gl_scanout(SpiceDisplayChannel *channel)
{
g_return_val_if_fail(SPICE_IS_DISPLAY_CHANNEL(channel), NULL);
- return &channel->priv->scanout;
+ return channel->priv->scanout.fd != -1 ? &channel->priv->scanout : NULL;
}
/* ------------------------------------------------------------------ */
diff --git a/src/spice-widget.c b/src/spice-widget.c
index 03c7cd8..a820ed2 100644
--- a/src/spice-widget.c
+++ b/src/spice-widget.c
@@ -2506,6 +2506,7 @@ static void gl_scanout(SpiceDisplay *display)
g_return_if_fail(d->egl.context_ready);
scanout = spice_display_get_gl_scanout(SPICE_DISPLAY_CHANNEL(d->display));
+ /* should only be called when the display has a scanout */
g_return_if_fail(scanout != NULL);
if (!spice_egl_update_scanout(display, scanout, &err)) {
--
2.5.5
More information about the Spice-devel
mailing list