[sysprof/wip/chergert/sysprof-3] backport weak pointers



commit fc30cfc2df466f7c34756dec5578c2dfc6eb1f2d
Author: Christian Hergert <chergert redhat com>
Date:   Thu May 16 22:45:45 2019 -0700

    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 45c9254..5c3e7b5 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 a57a35c..99d5bc6 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


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]