libsysprof-ui: track how many counters matched

This commit is contained in:
Christian Hergert
2019-08-02 10:59:08 -07:00
parent 5fa8c2dd1a
commit dbfa6c811b
2 changed files with 12 additions and 3 deletions

View File

@ -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));

View File

@ -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;