[gimp] app: unref the newly created GVariant-s.



commit 62827563c4113ef66ee1db7bba1d915f33b5020f
Author: Jehan <jehan girinstud io>
Date:   Sun Aug 22 11:25:15 2021 +0200

    app: unref the newly created GVariant-s.
    
    I first sink these, because they are floating references. This is
    actually quite unneeded here, because callbacks given to
    gimp_action_group_add_procedure_actions() (this is what
    filters_history_cmd_callback() is for) are not taking ownership of the
    GVariant anyway. Yet just in case this ever changes, this is the proper
    way to do it to avoid a double-free in the future. We take ownership in
    the calling code, hence we free the variable there after using it.

 app/actions/filters-commands.c | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)
---
diff --git a/app/actions/filters-commands.c b/app/actions/filters-commands.c
index 6ca05292d5..c322b96d3e 100644
--- a/app/actions/filters-commands.c
+++ b/app/actions/filters-commands.c
@@ -69,6 +69,7 @@ filters_apply_cmd_callback (GimpAction *action,
   gchar         *operation;
   GimpObject    *settings;
   GimpProcedure *procedure;
+  GVariant      *variant;
   return_if_no_drawable (image, drawable, data);
 
   operation = filters_parse_operation (image->gimp,
@@ -91,10 +92,12 @@ filters_apply_cmd_callback (GimpAction *action,
     g_object_unref (settings);
 
   gimp_filter_history_add (image->gimp, procedure);
-  filters_history_cmd_callback (NULL,
-                                g_variant_new_uint64 (GPOINTER_TO_SIZE (procedure)),
-                                data);
 
+  variant = g_variant_new_uint64 (GPOINTER_TO_SIZE (procedure));
+  g_variant_take_ref (variant);
+  filters_history_cmd_callback (NULL, variant, data);
+
+  g_variant_unref (variant);
   g_object_unref (procedure);
 }
 
@@ -106,6 +109,7 @@ filters_apply_interactive_cmd_callback (GimpAction *action,
   GimpImage     *image;
   GimpDrawable  *drawable;
   GimpProcedure *procedure;
+  GVariant      *variant;
   return_if_no_drawable (image, drawable, data);
 
   procedure = gimp_gegl_procedure_new (image->gimp,
@@ -118,10 +122,12 @@ filters_apply_interactive_cmd_callback (GimpAction *action,
                                        gimp_action_get_help_id (action));
 
   gimp_filter_history_add (image->gimp, procedure);
-  filters_history_cmd_callback (NULL,
-                                g_variant_new_uint64 (GPOINTER_TO_SIZE (procedure)),
-                                data);
 
+  variant = g_variant_new_uint64 (GPOINTER_TO_SIZE (procedure));
+  g_variant_take_ref (variant);
+  filters_history_cmd_callback (NULL, variant, data);
+
+  g_variant_unref (variant);
   g_object_unref (procedure);
 }
 


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