SystemMonitor: Don't try and show process window with nothing selected (#7221)

When right-clicking with no selected row in the process list,
SystemMonitor would still show a context menu. This disables
the context menu if index is invalid and also disables Alt+Enter
so that build_process_window() is never called with a PID of -1.

Fixes #7167.
This commit is contained in:
Marcus Nilsson 2021-05-18 08:10:27 +02:00 committed by GitHub
parent 325febf4e5
commit 63897c469b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
Notes: sideshowbarker 2024-07-18 17:53:12 +09:00

View file

@ -307,6 +307,8 @@ int main(int argc, char** argv)
auto process_properties_action = GUI::CommonActions::make_properties_action(
[&](auto&) {
auto pid = selected_id(ProcessModel::Column::PID);
if (pid == -1)
return;
RefPtr<GUI::Window> process_window;
auto it = process_windows.find(pid);
@ -341,7 +343,8 @@ int main(int argc, char** argv)
process_context_menu->add_separator();
process_context_menu->add_action(process_properties_action);
process_table_view.on_context_menu_request = [&]([[maybe_unused]] const GUI::ModelIndex& index, const GUI::ContextMenuEvent& event) {
process_context_menu->popup(event.screen_position(), process_properties_action);
if (index.is_valid())
process_context_menu->popup(event.screen_position(), process_properties_action);
};
auto& frequency_menu = menubar->add_menu("F&requency");