diff --git a/Libraries/LibCore/Timer.cpp b/Libraries/LibCore/Timer.cpp index f474c1cc715..87d91b0ff3b 100644 --- a/Libraries/LibCore/Timer.cpp +++ b/Libraries/LibCore/Timer.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018-2020, Andreas Kling + * Copyright (c) 2018-2025, Andreas Kling * Copyright (c) 2022, the SerenityOS developers. * * SPDX-License-Identifier: BSD-2-Clause @@ -14,28 +14,24 @@ NonnullRefPtr Timer::create() return adopt_ref(*new Timer); } -NonnullRefPtr Timer::create_repeating(int interval_ms, Function&& timeout_handler, EventReceiver* parent) +NonnullRefPtr Timer::create_repeating(int interval_ms, Function&& timeout_handler) { - return adopt_ref(*new Timer(interval_ms, move(timeout_handler), parent)); + return adopt_ref(*new Timer(interval_ms, move(timeout_handler))); } -NonnullRefPtr Timer::create_single_shot(int interval_ms, Function&& timeout_handler, EventReceiver* parent) +NonnullRefPtr Timer::create_single_shot(int interval_ms, Function&& timeout_handler) { - auto timer = adopt_ref(*new Timer(interval_ms, move(timeout_handler), parent)); + auto timer = adopt_ref(*new Timer(interval_ms, move(timeout_handler))); timer->set_single_shot(true); return timer; } Timer::~Timer() = default; -Timer::Timer(EventReceiver* parent) - : EventReceiver(parent) -{ -} +Timer::Timer() = default; -Timer::Timer(int interval_ms, Function&& timeout_handler, EventReceiver* parent) - : EventReceiver(parent) - , on_timeout(move(timeout_handler)) +Timer::Timer(int interval_ms, Function&& timeout_handler) + : on_timeout(move(timeout_handler)) , m_interval_ms(interval_ms) { } diff --git a/Libraries/LibCore/Timer.h b/Libraries/LibCore/Timer.h index 5b8ed2cd427..6fe9fe40e3f 100644 --- a/Libraries/LibCore/Timer.h +++ b/Libraries/LibCore/Timer.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018-2024, Andreas Kling + * Copyright (c) 2018-2025, Andreas Kling * Copyright (c) 2022, the SerenityOS developers. * * SPDX-License-Identifier: BSD-2-Clause @@ -17,8 +17,8 @@ class Timer final : public EventReceiver { public: static NonnullRefPtr create(); - static NonnullRefPtr create_repeating(int interval_ms, Function&& timeout_handler, EventReceiver* parent = nullptr); - static NonnullRefPtr create_single_shot(int interval_ms, Function&& timeout_handler, EventReceiver* parent = nullptr); + static NonnullRefPtr create_repeating(int interval_ms, Function&& timeout_handler); + static NonnullRefPtr create_single_shot(int interval_ms, Function&& timeout_handler); virtual ~Timer() override; @@ -46,8 +46,8 @@ public: Function on_timeout; private: - explicit Timer(EventReceiver* parent = nullptr); - Timer(int interval_ms, Function&& timeout_handler, EventReceiver* parent = nullptr); + Timer(); + Timer(int interval_ms, Function&& timeout_handler); virtual void timer_event(TimerEvent&) override;