summaryrefslogtreecommitdiff
path: root/Userland/Applications/SystemMonitor
diff options
context:
space:
mode:
authorcreator1creeper1 <creator1creeper1@airmail.cc>2022-01-09 13:00:51 +0100
committerAli Mohammad Pur <Ali.mpfard@gmail.com>2022-01-16 00:38:21 +0330
commit19d9d5bfe16c99aaa87d02ee2d38d9d8003c497d (patch)
treee9fa18627eacae297898f9029c2810d982eea89b /Userland/Applications/SystemMonitor
parent294cbb710802a1540b84e6c525ea118cab79f427 (diff)
downloadserenity-19d9d5bfe16c99aaa87d02ee2d38d9d8003c497d.zip
Everywhere: Mark Vector of mutable references as mutable
The point of a reference type is to behave just like the referred-to type. So, a Foo& should behave just like a Foo. In these cases, we had a const Vector. If it was a const Vector of Foo, iterating over the Vector would only permit taking const references to the individual Foos. However, we had a const Vector of Foo&. The behavior should not change. We should still only be permitted to take const references to the individual Foos. Otherwise, we would be allowed to mutate the individual Foos, which would mutate the elements of the const Vector. This wouldn't modify the stored pointers, but it would modify the objects that the references refer to. Since references should be transparent, this should not be legal. So it should be impossible to get mutable references into a const Vector. Since we need mutable references in these cases to call the mutating member functions, we need to mark the Vector as mutable as well.
Diffstat (limited to 'Userland/Applications/SystemMonitor')
-rw-r--r--Userland/Applications/SystemMonitor/main.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/Userland/Applications/SystemMonitor/main.cpp b/Userland/Applications/SystemMonitor/main.cpp
index 719a8defdf..061388d605 100644
--- a/Userland/Applications/SystemMonitor/main.cpp
+++ b/Userland/Applications/SystemMonitor/main.cpp
@@ -698,7 +698,7 @@ NonnullRefPtr<GUI::Widget> build_performance_tab()
cpu_graphs.append(cpu_graph);
}
}
- ProcessModel::the().on_cpu_info_change = [cpu_graphs](const NonnullOwnPtrVector<ProcessModel::CpuInfo>& cpus) {
+ ProcessModel::the().on_cpu_info_change = [cpu_graphs](const NonnullOwnPtrVector<ProcessModel::CpuInfo>& cpus) mutable {
float sum_cpu = 0;
for (size_t i = 0; i < cpus.size(); ++i) {
cpu_graphs[i].add_value({ static_cast<size_t>(cpus[i].total_cpu_percent), static_cast<size_t>(cpus[i].total_cpu_percent_kernel) });