mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-09 02:56:10 +00:00
LibCore+Userland: Don't auto-start new Core::Timers
This was unintuitive, and only useful in a few cases. In the majority, users had to immediately call `stop()`, and several who did want the timer started would call `start()` on it immediately anyway. Case in point: There are only two places I had to add a manual `start()`.
This commit is contained in:
parent
a8cf0c9371
commit
6edc0cf5ab
Notes:
sideshowbarker
2024-07-18 04:38:32 +09:00
Author: https://github.com/AtkinsSJ
Commit: 6edc0cf5ab
Pull-request: https://github.com/SerenityOS/serenity/pull/16960
Reviewed-by: https://github.com/alimpfard
10 changed files with 12 additions and 8 deletions
|
@ -18,15 +18,12 @@ class Timer final : public Object {
|
|||
public:
|
||||
static ErrorOr<NonnullRefPtr<Timer>> create_repeating(int interval_ms, Function<void()>&& timeout_handler, Object* parent = nullptr)
|
||||
{
|
||||
auto timer = TRY(adopt_nonnull_ref_or_enomem(new Timer(interval_ms, move(timeout_handler), parent)));
|
||||
timer->stop();
|
||||
return timer;
|
||||
return adopt_nonnull_ref_or_enomem(new Timer(interval_ms, move(timeout_handler), parent));
|
||||
}
|
||||
static ErrorOr<NonnullRefPtr<Timer>> create_single_shot(int interval_ms, Function<void()>&& timeout_handler, Object* parent = nullptr)
|
||||
{
|
||||
auto timer = TRY(adopt_nonnull_ref_or_enomem(new Timer(interval_ms, move(timeout_handler), parent)));
|
||||
timer->set_single_shot(true);
|
||||
timer->stop();
|
||||
return timer;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue