[sysprof] libsysprof-ui: track how many counters matched



commit dbfa6c811bfd48c28dbf4f94c78b79d775fb72c1
Author: Christian Hergert <chergert redhat com>
Date:   Fri Aug 2 10:59:08 2019 -0700

    libsysprof-ui: track how many counters matched

 src/libsysprof-ui/sysprof-battery-aid.c | 7 +++++--
 src/libsysprof-ui/sysprof-rapl-aid.c    | 8 +++++++-
 2 files changed, 12 insertions(+), 3 deletions(-)
---
diff --git a/src/libsysprof-ui/sysprof-battery-aid.c b/src/libsysprof-ui/sysprof-battery-aid.c
index 5675030..ab44a28 100644
--- a/src/libsysprof-ui/sysprof-battery-aid.c
+++ b/src/libsysprof-ui/sysprof-battery-aid.c
@@ -68,7 +68,7 @@ sysprof_battery_aid_new (void)
 
 static void
 sysprof_battery_aid_prepare (SysprofAid      *self,
-                         SysprofProfiler *profiler)
+                             SysprofProfiler *profiler)
 {
 #ifdef __linux__
   g_autoptr(SysprofSource) source = NULL;
@@ -175,6 +175,7 @@ sysprof_battery_aid_present_finish (SysprofAid    *aid,
     {
       g_autoptr(SysprofColorCycle) cycle = sysprof_color_cycle_new ();
       SysprofVisualizerGroup *group;
+      guint found = 0;
 
       group = g_object_new (SYSPROF_TYPE_VISUALIZER_GROUP,
                             "can-focus", TRUE,
@@ -209,10 +210,12 @@ sysprof_battery_aid_present_finish (SysprofAid    *aid,
                                                SYSPROF_VISUALIZER (row),
                                                is_combined ? 0 : -1,
                                                !is_combined);
+
+              found++;
             }
         }
 
-      if (counters->len > 0)
+      if (found > 0)
         sysprof_display_add_group (present->display, group);
       else
         gtk_widget_destroy (GTK_WIDGET (group));
diff --git a/src/libsysprof-ui/sysprof-rapl-aid.c b/src/libsysprof-ui/sysprof-rapl-aid.c
index b327d28..9da61d5 100644
--- a/src/libsysprof-ui/sysprof-rapl-aid.c
+++ b/src/libsysprof-ui/sysprof-rapl-aid.c
@@ -167,6 +167,7 @@ sysprof_rapl_aid_present_finish (SysprofAid    *aid,
       g_autoptr(GHashTable) cat_to_row = g_hash_table_new (g_str_hash, g_str_equal);
       SysprofVisualizerGroup *energy;
       SysprofVisualizer *all;
+      guint found = 0;
 
       energy = g_object_new (SYSPROF_TYPE_VISUALIZER_GROUP,
                              "can-focus", TRUE,
@@ -195,6 +196,7 @@ sysprof_rapl_aid_present_finish (SysprofAid    *aid,
 
               sysprof_color_cycle_next (cycle, &rgba);
               sysprof_line_visualizer_add_counter (SYSPROF_LINE_VISUALIZER (all), ctr->id, &rgba);
+              found++;
             }
           else if (g_str_has_prefix (ctr->category, "RAPL "))
             {
@@ -218,10 +220,14 @@ sysprof_rapl_aid_present_finish (SysprofAid    *aid,
 
               sysprof_color_cycle_next (cycle, &rgba);
               sysprof_line_visualizer_add_counter (SYSPROF_LINE_VISUALIZER (row), ctr->id, &rgba);
+              found++;
             }
         }
 
-      sysprof_display_add_group (present->display, energy);
+      if (found > 0)
+        sysprof_display_add_group (present->display, energy);
+      else
+        gtk_widget_destroy (GTK_WIDGET (energy));
     }
 
   return counters != NULL;


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