diff options
author | John Bundgaard <2511912+jbdk@users.noreply.github.com> | 2023-01-04 04:55:43 +0100 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2023-01-05 00:12:29 +0100 |
commit | badfe72b64338bdc2fe9a54c87f1a817e4ed7b02 (patch) | |
tree | 46ea6450b4bf3d6f00b8911796712a1546e2f50b /Userland | |
parent | f8ce211201bf40ee95e8b171799e576bf79a374a (diff) | |
download | serenity-badfe72b64338bdc2fe9a54c87f1a817e4ed7b02.zip |
SystemMonitor: Update stats/graph immediately on launch
Previously the stats was only updated once the first callback from
refresh_timer fired.
It now makes an early stats update on launch, so something will appear
in the graphs.
Diffstat (limited to 'Userland')
-rw-r--r-- | Userland/Applications/SystemMonitor/main.cpp | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/Userland/Applications/SystemMonitor/main.cpp b/Userland/Applications/SystemMonitor/main.cpp index 8f39f5a2f7..9d32074cfe 100644 --- a/Userland/Applications/SystemMonitor/main.cpp +++ b/Userland/Applications/SystemMonitor/main.cpp @@ -312,21 +312,22 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) Config::write_i32("SystemMonitor"sv, "Monitor"sv, "Frequency"sv, frequency); } - auto& refresh_timer = window->add<Core::Timer>( - frequency * 1000, [&] { - // FIXME: remove the primitive re-toggling code once persistent model indices work. - auto toggled_indices = process_table_view.selection().indices(); - toggled_indices.remove_all_matching([&](auto const& index) { return !process_table_view.is_toggled(index); }); - process_model->update(); - if (!process_table_view.selection().is_empty()) - process_table_view.selection().for_each_index([&](auto& selection) { - if (toggled_indices.contains_slow(selection)) - process_table_view.expand_all_parents_of(selection); - }); + auto update_stats = [&] { + // FIXME: remove the primitive re-toggling code once persistent model indices work. + auto toggled_indices = process_table_view.selection().indices(); + toggled_indices.remove_all_matching([&](auto const& index) { return !process_table_view.is_toggled(index); }); + process_model->update(); + if (!process_table_view.selection().is_empty()) + process_table_view.selection().for_each_index([&](auto& selection) { + if (toggled_indices.contains_slow(selection)) + process_table_view.expand_all_parents_of(selection); + }); - if (auto* memory_stats_widget = SystemMonitor::MemoryStatsWidget::the()) - memory_stats_widget->refresh(); - }); + if (auto* memory_stats_widget = SystemMonitor::MemoryStatsWidget::the()) + memory_stats_widget->refresh(); + }; + update_stats(); + auto& refresh_timer = window->add<Core::Timer>(frequency * 1000, move(update_stats)); auto selected_id = [&](ProcessModel::Column column) -> pid_t { if (process_table_view.selection().is_empty()) |