summaryrefslogtreecommitdiff
path: root/Applications
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2020-08-16 11:15:47 +0200
committerAndreas Kling <kling@serenityos.org>2020-08-16 16:44:09 +0200
commitb9ae937279e00fff4a8654db2a78e04cfd4096bb (patch)
treee4b7d0375b36ebbc2c857f8b9bfbf4e5e5bf69a0 /Applications
parent17992fbab738450c892ee283a642b8f4697fafde (diff)
downloadserenity-b9ae937279e00fff4a8654db2a78e04cfd4096bb.zip
SystemMonitor: Invalidate ProcessModel indexes when necessary
If the process table grows or shrinks, we need to invalidate all the ProcessModel indexes. This is not great, but it's the most precise invalidation we can do at the moment.
Diffstat (limited to 'Applications')
-rw-r--r--Applications/SystemMonitor/ProcessModel.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/Applications/SystemMonitor/ProcessModel.cpp b/Applications/SystemMonitor/ProcessModel.cpp
index 26b94d1606..bbe52779e0 100644
--- a/Applications/SystemMonitor/ProcessModel.cpp
+++ b/Applications/SystemMonitor/ProcessModel.cpp
@@ -352,6 +352,7 @@ GUI::Variant ProcessModel::data(const GUI::ModelIndex& index, Role role) const
void ProcessModel::update()
{
+ auto previous_pid_count = m_pids.size();
auto all_processes = Core::ProcessStatisticsReader::get_all();
unsigned last_sum_times_scheduled = 0;
@@ -434,5 +435,7 @@ void ProcessModel::update()
if (on_cpu_info_change)
on_cpu_info_change(m_cpus);
- did_update(GUI::Model::UpdateFlag::DontInvalidateIndexes);
+ // FIXME: This is a rather hackish way of invalidating indexes.
+ // It would be good if GUI::Model had a way to orchestrate removal/insertion while preserving indexes.
+ did_update(previous_pid_count == m_pids.size() ? GUI::Model::UpdateFlag::DontInvalidateIndexes : GUI::Model::UpdateFlag::InvalidateAllIndexes);
}