[gegl] gegl: use gegl_clear_pointer instead of some g_clear_pointer



commit 77382d0cbb03805372f4ebd83898057d7a8ace78
Author: Øyvind Kolås <pippin gimp org>
Date:   Mon Sep 24 14:55:10 2018 +0200

    gegl: use gegl_clear_pointer instead of some g_clear_pointer
    
    Thus avoding warnings on types caused by stricter expectation in glib
    implementation.

 gegl/gegl-utils.h                | 9 +++++++++
 gegl/module/geglmodule.c         | 2 +-
 gegl/process/gegl-eval-manager.c | 2 +-
 gegl/process/gegl-processor.c    | 7 ++++---
 4 files changed, 15 insertions(+), 5 deletions(-)
---
diff --git a/gegl/gegl-utils.h b/gegl/gegl-utils.h
index 1f9726ac0..91317188d 100644
--- a/gegl/gegl-utils.h
+++ b/gegl/gegl-utils.h
@@ -347,6 +347,15 @@ gchar *gegl_serialize  (GeglNode         *start,
 GeglNode *gegl_node_new_from_serialized (const gchar *chaindata,
                                          const gchar *path_root);
 
+
+#define gegl_clear_pointer(ptr, dfun) \
+  do { \
+    if (*ptr) { \
+      dfun(*ptr);\
+      *ptr = NULL;\
+    } \
+  } while(0)
+
 G_END_DECLS
 
 #endif /* __GEGL_UTILS_H__ */
diff --git a/gegl/module/geglmodule.c b/gegl/module/geglmodule.c
index 9f9b015f0..73a37fc0a 100644
--- a/gegl/module/geglmodule.c
+++ b/gegl/module/geglmodule.c
@@ -98,7 +98,7 @@ gegl_module_finalize (GObject *object)
 {
   GeglModule *module = GEGL_MODULE (object);
 
-  g_clear_pointer (&module->info, (GDestroyNotify) gegl_module_info_free);
+  gegl_clear_pointer (&module->info, gegl_module_info_free);
 
   g_free (module->last_module_error);
   g_free (module->filename);
diff --git a/gegl/process/gegl-eval-manager.c b/gegl/process/gegl-eval-manager.c
index 9d874c0f3..45305da06 100644
--- a/gegl/process/gegl-eval-manager.c
+++ b/gegl/process/gegl-eval-manager.c
@@ -59,7 +59,7 @@ gegl_eval_manager_finalize (GObject *self_object)
   GeglEvalManager *self = GEGL_EVAL_MANAGER (self_object);
 
   g_free (self->pad_name);
-  g_clear_pointer (&self->traversal, (GDestroyNotify) gegl_graph_free);
+  gegl_clear_pointer (&self->traversal, gegl_graph_free);
 
   g_signal_handlers_disconnect_by_data (self->node, self);
 
diff --git a/gegl/process/gegl-processor.c b/gegl/process/gegl-processor.c
index 8d1023b24..0778181a0 100644
--- a/gegl/process/gegl-processor.c
+++ b/gegl/process/gegl-processor.c
@@ -155,19 +155,20 @@ gegl_processor_constructed (GObject *object)
   processor->queued_region = gegl_region_new ();
 }
 
+
 static void
 gegl_processor_finalize (GObject *self_object)
 {
   GeglProcessor *processor = GEGL_PROCESSOR (self_object);
 
-  g_clear_pointer (&processor->context, (GDestroyNotify) gegl_operation_context_destroy);
+  gegl_clear_pointer (&processor->context, gegl_operation_context_destroy);
 
   g_clear_object (&processor->node);
   g_clear_object (&processor->real_node);
   g_clear_object (&processor->input);
 
-  g_clear_pointer (&processor->queued_region, (GDestroyNotify) gegl_region_destroy);
-  g_clear_pointer (&processor->valid_region, (GDestroyNotify) gegl_region_destroy);
+  gegl_clear_pointer (&processor->queued_region, gegl_region_destroy);
+  gegl_clear_pointer (&processor->valid_region, gegl_region_destroy);
 
   G_OBJECT_CLASS (gegl_processor_parent_class)->finalize (self_object);
 }


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