Skip to content
Snippets Groups Projects
Commit 1d65bc0f authored by Alexander Larsson's avatar Alexander Larsson
Browse files

Add backport of g_set_object

parent dade12b5
No related branches found
No related tags found
No related merge requests found
......@@ -38,4 +38,24 @@ glnx_strv_contains (const gchar * const *strv,
return FALSE;
}
gboolean
glnx_set_object (GObject **object_ptr,
GObject *new_object)
{
GObject *old_object = *object_ptr;
if (old_object == new_object)
return FALSE;
if (new_object != NULL)
g_object_ref (new_object);
*object_ptr = new_object;
if (old_object != NULL)
g_object_unref (old_object);
return TRUE;
}
#endif
......@@ -28,9 +28,19 @@
G_BEGIN_DECLS
#if !GLIB_CHECK_VERSION(2, 44, 0)
#define g_strv_contains glnx_strv_contains
gboolean glnx_strv_contains (const gchar * const *strv,
const gchar *str);
#define g_set_object(object_ptr, new_object) \
(/* Check types match. */ \
0 ? *(object_ptr) = (new_object), FALSE : \
glnx_set_object ((GObject **) (object_ptr), (GObject *) (new_object)) \
)
gboolean glnx_set_object (GObject **object_ptr,
GObject *new_object);
#endif /* !GLIB_CHECK_VERSION(2, 44, 0) */
G_END_DECLS
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment