gnucash stable: [window-main-summarybar.c] plug a GtkWidget* leak

Christopher Lam clam at code.gnucash.org
Sun Apr 19 18:53:32 EDT 2026


Updated	 via  https://github.com/Gnucash/gnucash/commit/60518c38 (commit)
	from  https://github.com/Gnucash/gnucash/commit/2e360ae0 (commit)



commit 60518c38374ceb3340db22580cb5c3ab6ce136d3
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Mon Apr 20 06:49:31 2026 +0800

    [window-main-summarybar.c] plug a GtkWidget* leak
    
    and don't need to copy a GdkRGBA object

diff --git a/gnucash/gnome-utils/window-main-summarybar.c b/gnucash/gnome-utils/window-main-summarybar.c
index 64d641b375..93a0f7de2f 100644
--- a/gnucash/gnome-utils/window-main-summarybar.c
+++ b/gnucash/gnome-utils/window-main-summarybar.c
@@ -444,19 +444,17 @@ static gchar*
 get_negative_color_str (void)
 {
     GdkRGBA color;
-    GdkRGBA *rgba;
     gchar *color_str;
     GtkWidget *label = gtk_label_new ("Color");
     GtkStyleContext *context = gtk_widget_get_style_context (GTK_WIDGET(label));
+    g_object_ref_sink (label);
     gtk_style_context_add_class (context, "gnc-class-negative-numbers");
     gtk_style_context_get_color (context, GTK_STATE_FLAG_NORMAL, &color);
-    rgba = gdk_rgba_copy (&color);
-
     color_str = g_strdup_printf ("#%02X%02X%02X",
-                              (int)(0.5 + CLAMP (rgba->red, 0., 1.) * 255.),
-                              (int)(0.5 + CLAMP (rgba->green, 0., 1.) * 255.),
-                              (int)(0.5 + CLAMP (rgba->blue, 0., 1.) * 255.));
-    gdk_rgba_free (rgba);
+                                 (int)(0.5 + CLAMP (color.red, 0., 1.) * 255.),
+                                 (int)(0.5 + CLAMP (color.green, 0., 1.) * 255.),
+                                 (int)(0.5 + CLAMP (color.blue, 0., 1.) * 255.));
+    g_object_unref (label);
     return color_str;
 }
 



Summary of changes:
 gnucash/gnome-utils/window-main-summarybar.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)



More information about the gnucash-changes mailing list