From dac11f11aafb09ab7fcd3e082086edbc9d31eeac Mon Sep 17 00:00:00 2001 From: Jehan Date: Sun, 7 Jul 2024 22:39:13 +0200 Subject: [PATCH] libgimp: add G_GNUC_WARN_UNUSED_RESULT to several functions. Functions creating a new GeglBuffer should trigger a warning if the result if unused, because this is potentially a big memory leak. Similarly objects created by functions creating new layers should be handled (usually by adding the layer to the image with gimp_image_insert_layer()), because they also come with a buffer and possibly quite some important memory leak. --- libgimp/gimpdrawable.h | 4 ++-- libgimp/gimpgrouplayer.h | 2 +- libgimp/gimplayer.h | 6 +++--- libgimp/gimptextlayer.h | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/libgimp/gimpdrawable.h b/libgimp/gimpdrawable.h index 614f65c6c8..b1412caba8 100644 --- a/libgimp/gimpdrawable.h +++ b/libgimp/gimpdrawable.h @@ -56,8 +56,8 @@ struct _GimpDrawableClass GimpDrawable * gimp_drawable_get_by_id (gint32 drawable_id); -GeglBuffer * gimp_drawable_get_buffer (GimpDrawable *drawable); -GeglBuffer * gimp_drawable_get_shadow_buffer (GimpDrawable *drawable); +GeglBuffer * gimp_drawable_get_buffer (GimpDrawable *drawable) G_GNUC_WARN_UNUSED_RESULT; +GeglBuffer * gimp_drawable_get_shadow_buffer (GimpDrawable *drawable) G_GNUC_WARN_UNUSED_RESULT; const Babl * gimp_drawable_get_format (GimpDrawable *drawable); const Babl * gimp_drawable_get_thumbnail_format (GimpDrawable *drawable); diff --git a/libgimp/gimpgrouplayer.h b/libgimp/gimpgrouplayer.h index 04a7e347f2..e039a4bfd3 100644 --- a/libgimp/gimpgrouplayer.h +++ b/libgimp/gimpgrouplayer.h @@ -41,7 +41,7 @@ G_DECLARE_FINAL_TYPE (GimpGroupLayer, gimp_group_layer, GIMP, GROUP_LAYER, GimpL GimpGroupLayer * gimp_group_layer_get_by_id (gint32 layer_id); GimpGroupLayer * gimp_group_layer_new (GimpImage *image, - const gchar *name); + const gchar *name) G_GNUC_WARN_UNUSED_RESULT; G_END_DECLS diff --git a/libgimp/gimplayer.h b/libgimp/gimplayer.h index e4b5660f31..7fc226837c 100644 --- a/libgimp/gimplayer.h +++ b/libgimp/gimplayer.h @@ -63,7 +63,7 @@ GimpLayer * gimp_layer_new (GimpImage *image, gint height, GimpImageType type, gdouble opacity, - GimpLayerMode mode); + GimpLayerMode mode) G_GNUC_WARN_UNUSED_RESULT; GimpLayer * gimp_layer_new_from_pixbuf (GimpImage *image, const gchar *name, @@ -71,12 +71,12 @@ GimpLayer * gimp_layer_new_from_pixbuf (GimpImage *image, gdouble opacity, GimpLayerMode mode, gdouble progress_start, - gdouble progress_end); + gdouble progress_end) G_GNUC_WARN_UNUSED_RESULT; GimpLayer * gimp_layer_new_from_surface (GimpImage *image, const gchar *name, cairo_surface_t *surface, gdouble progress_start, - gdouble progress_end); + gdouble progress_end) G_GNUC_WARN_UNUSED_RESULT; GimpLayer * gimp_layer_copy (GimpLayer *layer); diff --git a/libgimp/gimptextlayer.h b/libgimp/gimptextlayer.h index 58081136ee..75cc7658dc 100644 --- a/libgimp/gimptextlayer.h +++ b/libgimp/gimptextlayer.h @@ -44,7 +44,7 @@ GimpTextLayer * gimp_text_layer_new (GimpImage *image, const gchar *text, GimpFont *font, gdouble size, - GimpUnit unit); + GimpUnit unit) G_GNUC_WARN_UNUSED_RESULT; G_END_DECLS