mirror of
https://gitlab.uni-freiburg.de/opensourcevdi/spice
synced 2025-12-26 14:41:25 +00:00
display-channel: reuse function to set video codecs
Including g_clear_pointer() in glib-compat.h and using it to avoid warnings in odd situations. Signed-off-by: Victor Toso <victortoso@redhat.com> Acked-by: Frediano Ziglio <fziglio@redhat.com>
This commit is contained in:
parent
c6e8163093
commit
82165c10eb
@ -21,6 +21,7 @@
|
||||
#include <common/sw_canvas.h>
|
||||
|
||||
#include "display-channel-private.h"
|
||||
#include "glib-compat.h"
|
||||
|
||||
G_DEFINE_TYPE(DisplayChannel, display_channel, TYPE_COMMON_GRAPHICS_CHANNEL)
|
||||
|
||||
@ -62,10 +63,7 @@ display_channel_set_property(GObject *object,
|
||||
self->priv->n_surfaces = g_value_get_uint(value);
|
||||
break;
|
||||
case PROP_VIDEO_CODECS:
|
||||
if (self->priv->video_codecs) {
|
||||
g_array_unref(self->priv->video_codecs);
|
||||
}
|
||||
self->priv->video_codecs = g_array_ref(g_value_get_boxed(value));
|
||||
display_channel_set_video_codecs(self, g_value_get_boxed(value));
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec);
|
||||
@ -211,7 +209,7 @@ void display_channel_set_video_codecs(DisplayChannel *display, GArray *video_cod
|
||||
{
|
||||
spice_return_if_fail(display);
|
||||
|
||||
g_array_unref(display->priv->video_codecs);
|
||||
g_clear_pointer(&display->priv->video_codecs, g_array_unref);
|
||||
display->priv->video_codecs = g_array_ref(video_codecs);
|
||||
}
|
||||
|
||||
|
||||
@ -20,6 +20,25 @@
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
#if !GLIB_CHECK_VERSION(2,34,0)
|
||||
#define g_clear_pointer(pp, destroy) \
|
||||
G_STMT_START { \
|
||||
G_STATIC_ASSERT (sizeof *(pp) == sizeof (gpointer)); \
|
||||
/* Only one access, please */ \
|
||||
gpointer *_pp = (gpointer *) (pp); \
|
||||
gpointer _p; \
|
||||
/* This assignment is needed to avoid a gcc warning */ \
|
||||
GDestroyNotify _destroy = (GDestroyNotify) (destroy); \
|
||||
\
|
||||
_p = *_pp; \
|
||||
if (_p) \
|
||||
{ \
|
||||
*_pp = NULL; \
|
||||
_destroy (_p); \
|
||||
} \
|
||||
} G_STMT_END
|
||||
#endif
|
||||
|
||||
#if !GLIB_CHECK_VERSION(2,32,0)
|
||||
static inline void
|
||||
g_queue_free_full(GQueue *queue, GDestroyNotify free_func)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user