summaryrefslogtreecommitdiff
path: root/Userland/Applications/SystemMonitor/ProcessModel.h
diff options
context:
space:
mode:
authorkleines Filmröllchen <filmroellchen@serenityos.org>2022-04-06 14:55:20 +0200
committerAndreas Kling <kling@serenityos.org>2022-04-06 22:41:54 +0200
commitbafaff61c9b7b870cacbf61f6fb1a1f26e5d27b7 (patch)
tree698ce63be166c86a1358fcefc35a3c7497ded256 /Userland/Applications/SystemMonitor/ProcessModel.h
parent0f6e1f7a326d3b13ed3639b970027c821e6251e6 (diff)
downloadserenity-bafaff61c9b7b870cacbf61f6fb1a1f26e5d27b7.zip
SystemMonitor: Fallback to invalid model index if there's no main thread
In the process model we check the thread with tid=pid to figure out the main thread of a process. This is used to construct the process view tree with non-main threads listed as children of the process row. However, there are sometimes circumstances where there is no main thread, even though the process should have been removed from the internal list by then. As a safe fallback, let's default to an invalid model index if we can't figure out what the main thread of a process is.
Diffstat (limited to 'Userland/Applications/SystemMonitor/ProcessModel.h')
-rw-r--r--Userland/Applications/SystemMonitor/ProcessModel.h4
1 files changed, 2 insertions, 2 deletions
diff --git a/Userland/Applications/SystemMonitor/ProcessModel.h b/Userland/Applications/SystemMonitor/ProcessModel.h
index 93f7618f46..d8daecbeef 100644
--- a/Userland/Applications/SystemMonitor/ProcessModel.h
+++ b/Userland/Applications/SystemMonitor/ProcessModel.h
@@ -210,9 +210,9 @@ private:
return this->pid == other.pid;
}
- NonnullRefPtr<Thread> main_thread() const
+ Optional<NonnullRefPtr<Thread>> main_thread() const
{
- return *threads.first_matching([this](auto const thread) { return thread->current_state.tid == pid; }).value();
+ return threads.first_matching([this](auto const thread) { return thread->current_state.tid == pid; });
}
// Return anything but the main thread; therefore, valid indices are anything up to threads.size()-1 exclusive.