[gnome-applets] cpufreq: fix memory leak



commit 4346de1932f788c1ab3c2323b100ea2bd1e18018
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date:   Fri Mar 27 17:37:05 2020 +0200

    cpufreq: fix memory leak
    
    gtk_widget_destroy only calls g_object_run_dispose which normally
    would unparent/remove widget from container but as we do not add
    widget to container its floating reference is never removed and
    widget is not destroyed.
    
    https://gitlab.gnome.org/GNOME/gnome-panel/-/issues/21

 cpufreq/src/cpufreq-applet.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
---
diff --git a/cpufreq/src/cpufreq-applet.c b/cpufreq/src/cpufreq-applet.c
index eeba30732..8a27daf51 100644
--- a/cpufreq/src/cpufreq-applet.c
+++ b/cpufreq/src/cpufreq-applet.c
@@ -337,10 +337,11 @@ get_text_width (const gchar *text)
 
         width = 0;
         label = gtk_label_new (text);
+        g_object_ref_sink (label);
 
         gtk_widget_show (label);
         gtk_widget_get_preferred_width (label, &width, NULL);
-        gtk_widget_destroy (label);
+        g_object_unref (label);
 
         return width;
 }


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