diff --git a/src/libsysprof-ui/sysprof-battery-aid.c b/src/libsysprof-ui/sysprof-battery-aid.c index 5675030c..ab44a281 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 b327d28c..9da61d56 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;