netstar pushed a commit to branch master.

http://git.enlightenment.org/apps/evisum.git/commit/?id=f4a6fb8166216a07756882044d82ce3feb1654bf

commit f4a6fb8166216a07756882044d82ce3feb1654bf
Author: Alastair Poole <nets...@gmail.com>
Date:   Wed Feb 24 22:27:11 2021 +0000

    proclist: fix that leak.
    
    custom callback pointer is being leaked in elm_progressbar.
    2 pointers / 16 bytes. This is ... not leaking
---
 src/bin/ui/ui_process_list.c | 38 ++++++--------------------------------
 1 file changed, 6 insertions(+), 32 deletions(-)

diff --git a/src/bin/ui/ui_process_list.c b/src/bin/ui/ui_process_list.c
index 4c7ed5b..0407e7c 100644
--- a/src/bin/ui/ui_process_list.c
+++ b/src/bin/ui/ui_process_list.c
@@ -12,7 +12,6 @@
 #include <sys/resource.h>
 #include <pwd.h>
 
-#define PROGRESS_CUSTOM_FORMAT 1
 #define DIRTY_GENLIST_HACK     1
 
 extern int EVISUM_EVENT_CONFIG_CHANGED;
@@ -94,10 +93,6 @@ typedef struct
 
 static Ui_Data *_pd = NULL;
 
-#if PROGRESS_CUSTOM_FORMAT
-static double _cpu_usage = 0.0;
-#endif
-
 typedef struct
 {
    Proc_Field   id;
@@ -317,24 +312,6 @@ _item_column_add(Evas_Object *tb, const char *text, int 
col)
    return lb;
 }
 
-#if PROGRESS_CUSTOM_FORMAT
-static char *
-_pb_format_cb(double val)
-{
-   static char buf[32];
-
-   snprintf(buf, sizeof(buf), "%1.1f %%", _cpu_usage);
-
-   return strdup(buf);
-}
-
-static void
-_pb_format_free_cb(char *str)
-{
-   free(str);
-}
-#endif
-
 static Evas_Object *
 _item_create(Evas_Object *obj)
 {
@@ -444,11 +421,6 @@ _item_create(Evas_Object *obj)
         evas_object_size_hint_weight_set(pb, EXPAND, EXPAND);
         evas_object_size_hint_align_set(pb, FILL, FILL);
         elm_progressbar_unit_format_set(pb, "%1.1f %%");
-#if PROGRESS_CUSTOM_FORMAT
-        elm_progressbar_unit_format_function_set(pb,
-                                                 _pb_format_cb,
-                                                 _pb_format_free_cb);
-#endif
         elm_table_pack(tb, pb, i++, 0, 1, 1);
         evas_object_data_set(tb, "proc_cpu_usage", pb);
      }
@@ -680,13 +652,15 @@ _content_get(void *data, Evas_Object *obj, const char 
*source)
    if (_field_enabled(PROC_FIELD_CPU_USAGE))
      {
         pb = evas_object_data_get(it->obj, "proc_cpu_usage");
-#if PROGRESS_CUSTOM_FORMAT
-        _cpu_usage = proc->cpu_usage;
-#endif
         double value = proc->cpu_usage / 100.0;
         double last = elm_progressbar_value_get(pb);
+
         if (!EINA_DBL_EQ(value, last))
-          elm_progressbar_value_set(pb, proc->cpu_usage / 100.0);
+          {
+             elm_progressbar_value_set(pb, proc->cpu_usage / 100.0);
+             snprintf(buf, sizeof(buf), "%1.1f %%", proc->cpu_usage);
+             elm_object_part_text_set(pb, "elm.text.status", buf);
+          }
         evas_object_show(pb);
      }
 

-- 


Reply via email to