From 63f785563db3828dbea5678a60b478eace2ff526 Mon Sep 17 00:00:00 2001 From: apio Date: Fri, 19 Jan 2024 21:11:03 +0100 Subject: [PATCH] terminal: Use proper lambda functions when registering a fd listener for the pseudoterminal --- terminal/TerminalWidget.cpp | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/terminal/TerminalWidget.cpp b/terminal/TerminalWidget.cpp index 98e56ab4..f495fd40 100644 --- a/terminal/TerminalWidget.cpp +++ b/terminal/TerminalWidget.cpp @@ -35,8 +35,6 @@ static void sigchld_handler(int) ui::App::the().set_should_close(true); } -TerminalWidget* s_main = nullptr; - Result TerminalWidget::init(char* const* args) { m_font = ui::Font::default_font(); @@ -62,17 +60,10 @@ Result TerminalWidget::init(char* const* args) fcntl(m_pty, F_SETFL, O_NONBLOCK); - // FIXME: Find a better solution for this. What if the caller needs several TerminalWidgets in one app? We can't - // just use a singleton, can we? - os::EventLoop::the().register_fd_listener(m_pty, [](int, int) { - check(s_main); - s_main->process(); - }); + os::EventLoop::the().register_fd_listener(m_pty, [this](int, int) { this->process(); }); m_child_pid = child; - s_main = this; - return {}; }