From dd724fe77a65e00a7b58eb8ccabcf2d7f0caa304 Mon Sep 17 00:00:00 2001 From: Christian Hergert Date: Thu, 16 May 2019 22:45:45 -0700 Subject: [PATCH] backport weak pointers --- src/libsysprof-ui/sysprof-tab.c | 1 + src/libsysprof-ui/sysprof-ui-private.h | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/src/libsysprof-ui/sysprof-tab.c b/src/libsysprof-ui/sysprof-tab.c index 45c9254f..5c3e7b5a 100644 --- a/src/libsysprof-ui/sysprof-tab.c +++ b/src/libsysprof-ui/sysprof-tab.c @@ -24,6 +24,7 @@ #include "sysprof-display.h" #include "sysprof-tab.h" +#include "sysprof-ui-private.h" struct _SysprofTab { diff --git a/src/libsysprof-ui/sysprof-ui-private.h b/src/libsysprof-ui/sysprof-ui-private.h index a57a35cc..99d5bc64 100644 --- a/src/libsysprof-ui/sysprof-ui-private.h +++ b/src/libsysprof-ui/sysprof-ui-private.h @@ -47,4 +47,11 @@ void _sysprof_rounded_rectangle (cairo_t G_DEFINE_AUTOPTR_CLEANUP_FUNC (SysprofMarkStat, _sysprof_mark_stat_free) +#if !GLIB_CHECK_VERSION(2, 56, 0) +# define g_clear_weak_pointer(ptr) \ + (*(ptr) ? (g_object_remove_weak_pointer((GObject*)*(ptr), (gpointer*)ptr),*(ptr)=NULL,1) : 0) +# define g_set_weak_pointer(ptr,obj) \ + ((obj!=*(ptr))?(g_clear_weak_pointer(ptr),*(ptr)=obj,((obj)?g_object_add_weak_pointer((GObject*)obj,(gpointer*)ptr),NULL:NULL),1):0) +#endif + G_END_DECLS