From ebb96b7fead08b64b8a771b9f0a3ff51820b7aaf Mon Sep 17 00:00:00 2001 From: Marcus Nilsson Date: Wed, 28 Jul 2021 00:23:34 +0200 Subject: [PATCH] SystemMonitor: Only update kill actions when pid changes Return early from on_selection_change if the pid hasn't changed or we get an invalid result from selected_id(). --- Userland/Applications/SystemMonitor/main.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Userland/Applications/SystemMonitor/main.cpp b/Userland/Applications/SystemMonitor/main.cpp index 5afeae9461..7e12aade14 100644 --- a/Userland/Applications/SystemMonitor/main.cpp +++ b/Userland/Applications/SystemMonitor/main.cpp @@ -353,8 +353,13 @@ int main(int argc, char** argv) process_properties_action->activate(); }; + static pid_t last_selected_pid; + process_table_view.on_selection_change = [&] { pid_t pid = selected_id(ProcessModel::Column::PID); + if (pid == last_selected_pid || pid < 1) + return; + last_selected_pid = pid; bool has_access = can_access_pid(pid); kill_action->set_enabled(has_access); stop_action->set_enabled(has_access);