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;