From cbc582e0dfbbd8345342971b56362f366c65579c Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Mon, 5 Apr 2021 11:29:18 +0200 Subject: [PATCH] SystemMonitor: Don't generate backtraces while not looking at them --- .../SystemMonitor/ThreadStackWidget.cpp | 15 ++++++++++++--- .../SystemMonitor/ThreadStackWidget.h | 3 +++ 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/Userland/Applications/SystemMonitor/ThreadStackWidget.cpp b/Userland/Applications/SystemMonitor/ThreadStackWidget.cpp index d7aa93d589..3778510658 100644 --- a/Userland/Applications/SystemMonitor/ThreadStackWidget.cpp +++ b/Userland/Applications/SystemMonitor/ThreadStackWidget.cpp @@ -37,21 +37,30 @@ ThreadStackWidget::ThreadStackWidget() layout()->set_margins({ 4, 4, 4, 4 }); m_stack_editor = add(); m_stack_editor->set_mode(GUI::TextEditor::ReadOnly); - - m_timer = add(1000, [this] { refresh(); }); } ThreadStackWidget::~ThreadStackWidget() { } +void ThreadStackWidget::show_event(GUI::ShowEvent&) +{ + refresh(); + if (!m_timer) + m_timer = add(1000, [this] { refresh(); }); +} + +void ThreadStackWidget::hide_event(GUI::HideEvent&) +{ + m_timer = nullptr; +} + void ThreadStackWidget::set_ids(pid_t pid, pid_t tid) { if (m_pid == pid && m_tid == tid) return; m_pid = pid; m_tid = tid; - refresh(); } void ThreadStackWidget::refresh() diff --git a/Userland/Applications/SystemMonitor/ThreadStackWidget.h b/Userland/Applications/SystemMonitor/ThreadStackWidget.h index 5a10e93b0a..98bcf43ea0 100644 --- a/Userland/Applications/SystemMonitor/ThreadStackWidget.h +++ b/Userland/Applications/SystemMonitor/ThreadStackWidget.h @@ -40,6 +40,9 @@ public: private: ThreadStackWidget(); + virtual void show_event(GUI::ShowEvent&) override; + virtual void hide_event(GUI::HideEvent&) override; + pid_t m_pid { -1 }; pid_t m_tid { -1 }; RefPtr m_stack_editor;