summaryrefslogtreecommitdiff
path: root/Userland
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2021-04-05 11:29:18 +0200
committerAndreas Kling <kling@serenityos.org>2021-04-05 11:42:54 +0200
commitcbc582e0dfbbd8345342971b56362f366c65579c (patch)
tree67af086846d00285cae9d5694bf9a5ff10e3b849 /Userland
parent3bb36dbd3f97a94adaf442643983e6111c82ae4d (diff)
downloadserenity-cbc582e0dfbbd8345342971b56362f366c65579c.zip
SystemMonitor: Don't generate backtraces while not looking at them
Diffstat (limited to 'Userland')
-rw-r--r--Userland/Applications/SystemMonitor/ThreadStackWidget.cpp15
-rw-r--r--Userland/Applications/SystemMonitor/ThreadStackWidget.h3
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<GUI::TextEditor>();
m_stack_editor->set_mode(GUI::TextEditor::ReadOnly);
-
- m_timer = add<Core::Timer>(1000, [this] { refresh(); });
}
ThreadStackWidget::~ThreadStackWidget()
{
}
+void ThreadStackWidget::show_event(GUI::ShowEvent&)
+{
+ refresh();
+ if (!m_timer)
+ m_timer = add<Core::Timer>(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<GUI::TextEditor> m_stack_editor;