diff --git a/Ladybird/AppKit/UI/TaskManager.mm b/Ladybird/AppKit/UI/TaskManager.mm index 2997c13c48e..eb0e2f21d17 100644 --- a/Ladybird/AppKit/UI/TaskManager.mm +++ b/Ladybird/AppKit/UI/TaskManager.mm @@ -55,14 +55,14 @@ static constexpr CGFloat const WINDOW_HEIGHT = 300; __weak TaskManager* weak_self = self; - m_update_timer = MUST(Core::Timer::create_repeating(1000, [weak_self] { + m_update_timer = Core::Timer::create_repeating(1000, [weak_self] { TaskManager* strong_self = weak_self; if (strong_self == nil) { return; } [strong_self updateStatistics]; - })); + }); [self setContentView:scroll_view]; [self setTitle:@"Task Manager"]; diff --git a/Tests/LibCore/TestLibCoreDeferredInvoke.cpp b/Tests/LibCore/TestLibCoreDeferredInvoke.cpp index 906b6e8aba1..097d22ab5e4 100644 --- a/Tests/LibCore/TestLibCoreDeferredInvoke.cpp +++ b/Tests/LibCore/TestLibCoreDeferredInvoke.cpp @@ -12,10 +12,10 @@ TEST_CASE(deferred_invoke) { Core::EventLoop event_loop; - auto reaper = MUST(Core::Timer::create_single_shot(250, [] { + auto reaper = Core::Timer::create_single_shot(250, [] { warnln("I waited for the deferred_invoke to happen, but it never did!"); VERIFY_NOT_REACHED(); - })); + }); Core::deferred_invoke([&event_loop] { event_loop.quit(0); diff --git a/Tests/LibCore/TestLibCoreFileWatcher.cpp b/Tests/LibCore/TestLibCoreFileWatcher.cpp index 39c91630833..aec7adb6a42 100644 --- a/Tests/LibCore/TestLibCoreFileWatcher.cpp +++ b/Tests/LibCore/TestLibCoreFileWatcher.cpp @@ -43,21 +43,21 @@ TEST_CASE(file_watcher_child_events) event_count++; }; - auto timer1 = MUST(Core::Timer::create_single_shot(500, [&] { + auto timer1 = Core::Timer::create_single_shot(500, [&] { int rc = creat("/tmp/testfile", 0777); EXPECT_NE(rc, -1); - })); + }); timer1->start(); - auto timer2 = MUST(Core::Timer::create_single_shot(1000, [&] { + auto timer2 = Core::Timer::create_single_shot(1000, [&] { int rc = unlink("/tmp/testfile"); EXPECT_NE(rc, -1); - })); + }); timer2->start(); - auto catchall_timer = MUST(Core::Timer::create_single_shot(2000, [&] { + auto catchall_timer = Core::Timer::create_single_shot(2000, [&] { VERIFY_NOT_REACHED(); - })); + }); catchall_timer->start(); event_loop.exec(); diff --git a/Userland/Applications/Assistant/main.cpp b/Userland/Applications/Assistant/main.cpp index f265ef62f24..b9983ac4f0c 100644 --- a/Userland/Applications/Assistant/main.cpp +++ b/Userland/Applications/Assistant/main.cpp @@ -241,7 +241,7 @@ ErrorOr serenity_main(Main::Arguments arguments) GUI::Application::the()->quit(); }; - auto update_ui_timer = TRY(Core::Timer::create_single_shot(10, [&] { + auto update_ui_timer = Core::Timer::create_single_shot(10, [&] { results_container.remove_all_children(); results_container.layout()->set_margins(app_state.visible_result_count ? GUI::Margins { 4, 0, 0, 0 } : GUI::Margins { 0 }); @@ -259,7 +259,7 @@ ErrorOr serenity_main(Main::Arguments arguments) mark_selected_item(); Core::deferred_invoke([window] { window->resize(GUI::Desktop::the().rect().width() / 3, {}); }); - })); + }); db.on_new_results = [&](auto results) { if (results.is_empty()) { diff --git a/Userland/Applications/Browser/TaskManagerWidget.cpp b/Userland/Applications/Browser/TaskManagerWidget.cpp index 43e57215bde..de3c3c06a3f 100644 --- a/Userland/Applications/Browser/TaskManagerWidget.cpp +++ b/Userland/Applications/Browser/TaskManagerWidget.cpp @@ -15,9 +15,9 @@ TaskManagerWidget::~TaskManagerWidget() = default; TaskManagerWidget::TaskManagerWidget() { - m_update_timer = MUST(Core::Timer::create_repeating(1000, [this] { + m_update_timer = Core::Timer::create_repeating(1000, [this] { this->update_statistics(); - })); + }); m_update_timer->start(); m_web_view = add(); diff --git a/Userland/Applications/ClockSettings/ClockSettingsWidget.cpp b/Userland/Applications/ClockSettings/ClockSettingsWidget.cpp index b7ace31596b..427b3e4e3d2 100644 --- a/Userland/Applications/ClockSettings/ClockSettingsWidget.cpp +++ b/Userland/Applications/ClockSettings/ClockSettingsWidget.cpp @@ -94,9 +94,9 @@ ErrorOr ClockSettingsWidget::setup() set_modified(true); }; - m_clock_preview_update_timer = TRY(Core::Timer::create_repeating(1000, [&]() { + m_clock_preview_update_timer = Core::Timer::create_repeating(1000, [&]() { update_clock_preview(); - })); + }); m_clock_preview_update_timer->start(); update_clock_preview(); diff --git a/Userland/Applications/DisplaySettings/MonitorSettingsWidget.cpp b/Userland/Applications/DisplaySettings/MonitorSettingsWidget.cpp index 30b57eb2a24..ad1a751b290 100644 --- a/Userland/Applications/DisplaySettings/MonitorSettingsWidget.cpp +++ b/Userland/Applications/DisplaySettings/MonitorSettingsWidget.cpp @@ -271,7 +271,7 @@ void MonitorSettingsWidget::apply_settings() box->set_icon(window()->icon()); // If after 10 seconds the user doesn't close the message box, just close it. - auto revert_timer_or_error = Core::Timer::create_repeating(1000, [&] { + auto revert_timer = Core::Timer::create_repeating(1000, [&] { seconds_until_revert -= 1; current_box_text_or_error = box_text(); if (current_box_text_or_error.is_error()) { @@ -285,11 +285,6 @@ void MonitorSettingsWidget::apply_settings() box->close(); } }); - if (revert_timer_or_error.is_error()) { - GUI::MessageBox::show_error(window(), "Unable to apply changes"sv); - return; - } - auto revert_timer = revert_timer_or_error.release_value(); revert_timer->start(); // If the user selects "No", closes the window or the window gets closed by the 10 seconds timer, revert the changes. diff --git a/Userland/Applications/MouseSettings/HighlightPreviewWidget.cpp b/Userland/Applications/MouseSettings/HighlightPreviewWidget.cpp index f46018b2c36..afec91787e1 100644 --- a/Userland/Applications/MouseSettings/HighlightPreviewWidget.cpp +++ b/Userland/Applications/MouseSettings/HighlightPreviewWidget.cpp @@ -37,10 +37,10 @@ ErrorOr HighlightPreviewWidget::reload_cursor() m_cursor_params = Gfx::CursorParams::parse_from_filename(cursor_path, m_cursor_bitmap->rect().center()).constrained(*m_cursor_bitmap); // Setup cursor animation: if (m_cursor_params.frames() > 1 && m_cursor_params.frame_ms() > 0) { - m_frame_timer = TRY(Core::Timer::create_repeating(m_cursor_params.frame_ms(), [&] { + m_frame_timer = Core::Timer::create_repeating(m_cursor_params.frame_ms(), [&] { m_cursor_frame = (m_cursor_frame + 1) % m_cursor_params.frames(); update(); - })); + }); m_frame_timer->start(); } else { m_frame_timer = nullptr; diff --git a/Userland/Applications/Piano/main.cpp b/Userland/Applications/Piano/main.cpp index 970193b7528..b1eb122167b 100644 --- a/Userland/Applications/Piano/main.cpp +++ b/Userland/Applications/Piano/main.cpp @@ -54,10 +54,10 @@ ErrorOr serenity_main(Main::Arguments arguments) auto wav_progress_window = ExportProgressWindow::construct(*window, wav_percent_written); TRY(wav_progress_window->initialize()); - auto main_widget_updater = TRY(Core::Timer::create_repeating(static_cast((1 / 30.0) * 1000), [&] { + auto main_widget_updater = Core::Timer::create_repeating(static_cast((1 / 30.0) * 1000), [&] { if (window->is_active()) Core::EventLoop::current().post_event(main_widget, make(0)); - })); + }); main_widget_updater->start(); auto file_menu = window->add_menu("&File"_string); diff --git a/Userland/Applications/PixelPaint/Filters/Filter.cpp b/Userland/Applications/PixelPaint/Filters/Filter.cpp index 457dccf562e..7acb7522dcb 100644 --- a/Userland/Applications/PixelPaint/Filters/Filter.cpp +++ b/Userland/Applications/PixelPaint/Filters/Filter.cpp @@ -17,7 +17,7 @@ Filter::Filter(ImageEditor* editor) , m_update_timer(Core::Timer::create_single_shot(100, [&] { if (on_settings_change) on_settings_change(); - }).release_value_but_fixme_should_propagate_errors()) + })) { m_update_timer->set_active(false); } diff --git a/Userland/Applications/PixelPaint/ImageEditor.cpp b/Userland/Applications/PixelPaint/ImageEditor.cpp index d934cdf35d8..321172f7a6f 100644 --- a/Userland/Applications/PixelPaint/ImageEditor.cpp +++ b/Userland/Applications/PixelPaint/ImageEditor.cpp @@ -51,7 +51,7 @@ ImageEditor::ImageEditor(NonnullRefPtr image) m_marching_ants_offset %= (marching_ant_length * 2); if (!m_image->selection().is_empty() || m_image->selection().in_interactive_selection()) update(); - }).release_value_but_fixme_should_propagate_errors(); + }); m_marching_ants_timer->start(); } diff --git a/Userland/Applications/PixelPaint/Tools/SprayTool.cpp b/Userland/Applications/PixelPaint/Tools/SprayTool.cpp index c7bfd3ea440..5f2b5a58a62 100644 --- a/Userland/Applications/PixelPaint/Tools/SprayTool.cpp +++ b/Userland/Applications/PixelPaint/Tools/SprayTool.cpp @@ -24,7 +24,7 @@ SprayTool::SprayTool() { m_timer = Core::Timer::create_repeating(200, [&]() { paint_it(); - }).release_value_but_fixme_should_propagate_errors(); + }); } static double nrand() diff --git a/Userland/Applications/PixelPaint/Tools/TextTool.cpp b/Userland/Applications/PixelPaint/Tools/TextTool.cpp index 32975110bd5..ebd61b2ee64 100644 --- a/Userland/Applications/PixelPaint/Tools/TextTool.cpp +++ b/Userland/Applications/PixelPaint/Tools/TextTool.cpp @@ -44,7 +44,7 @@ TextTool::TextTool() m_text_editor->set_font(m_selected_font); m_cursor_blink_timer = Core::Timer::create_repeating(500, [&]() { m_cursor_blink_state = !m_cursor_blink_state; - }).release_value_but_fixme_should_propagate_errors(); + }); } void TextTool::on_primary_color_change(Color color) diff --git a/Userland/Applications/SoundPlayer/PlaybackManager.cpp b/Userland/Applications/SoundPlayer/PlaybackManager.cpp index c5b3f430acb..df441b27617 100644 --- a/Userland/Applications/SoundPlayer/PlaybackManager.cpp +++ b/Userland/Applications/SoundPlayer/PlaybackManager.cpp @@ -15,7 +15,7 @@ PlaybackManager::PlaybackManager(NonnullRefPtr connec if (!m_loader) return; next_buffer(); - }).release_value_but_fixme_should_propagate_errors(); + }); } void PlaybackManager::set_loader(NonnullRefPtr&& loader) diff --git a/Userland/Applications/Terminal/main.cpp b/Userland/Applications/Terminal/main.cpp index a7ef2f9bf69..672e2d2f4f1 100644 --- a/Userland/Applications/Terminal/main.cpp +++ b/Userland/Applications/Terminal/main.cpp @@ -453,9 +453,9 @@ ErrorOr serenity_main(Main::Arguments arguments) TRY(Core::System::unveil("/tmp/session/%sid/portal/config", "rw")); TRY(Core::System::unveil(nullptr, nullptr)); - auto modified_state_check_timer = TRY(Core::Timer::create_repeating(500, [&] { + auto modified_state_check_timer = Core::Timer::create_repeating(500, [&] { window->set_modified(tty_has_foreground_process() || shell_child_process_count() > 0); - })); + }); listener.on_confirm_close_changed = [&](bool confirm_close) { if (confirm_close) { diff --git a/Userland/Demos/CatDog/main.cpp b/Userland/Demos/CatDog/main.cpp index 1124bd5db96..408df755d14 100644 --- a/Userland/Demos/CatDog/main.cpp +++ b/Userland/Demos/CatDog/main.cpp @@ -64,14 +64,14 @@ ErrorOr serenity_main(Main::Arguments arguments) auto advice_widget = advice_window->set_main_widget(catdog_widget); advice_widget->set_layout(GUI::Margins {}, 0); - auto advice_timer = TRY(Core::Timer::create_single_shot(15'000, [&] { + auto advice_timer = Core::Timer::create_single_shot(15'000, [&] { window->move_to_front(); advice_window->move_to_front(); catdog_widget->set_roaming(false); advice_window->move_to(window->x() - advice_window->width() / 2, window->y() - advice_window->height()); advice_window->show(); advice_window->set_always_on_top(); - })); + }); advice_timer->start(); advice_widget->on_dismiss = [&] { diff --git a/Userland/Demos/WidgetGallery/DemoWizardDialog.cpp b/Userland/Demos/WidgetGallery/DemoWizardDialog.cpp index 8a671f40b29..4b3664d89cb 100644 --- a/Userland/Demos/WidgetGallery/DemoWizardDialog.cpp +++ b/Userland/Demos/WidgetGallery/DemoWizardDialog.cpp @@ -57,8 +57,7 @@ DemoWizardDialog::DemoWizardDialog(GUI::Window* parent_window) replace_page(*m_back_page); } }, - this) - .release_value_but_fixme_should_propagate_errors(); + this); m_page_2->on_page_enter = [&]() { m_page_2_progress_value = 0; m_page_2_timer->restart(); diff --git a/Userland/DevTools/HackStudio/Editor.cpp b/Userland/DevTools/HackStudio/Editor.cpp index 14789139fb8..e28078424a8 100644 --- a/Userland/DevTools/HackStudio/Editor.cpp +++ b/Userland/DevTools/HackStudio/Editor.cpp @@ -762,7 +762,7 @@ void Editor::create_tokens_info_timer() m_tokens_info_timer = Core::Timer::create_repeating((int)token_info_timer_interval_ms, [this] { on_token_info_timer_tick(); m_tokens_info_timer->stop(); - }).release_value_but_fixme_should_propagate_errors(); + }); m_tokens_info_timer->start(); } diff --git a/Userland/DevTools/Profiler/main.cpp b/Userland/DevTools/Profiler/main.cpp index 00df1388b01..4308235cd49 100644 --- a/Userland/DevTools/Profiler/main.cpp +++ b/Userland/DevTools/Profiler/main.cpp @@ -329,7 +329,7 @@ static bool prompt_to_stop_profiling(pid_t pid, ByteString const& process_name) clock.start(); auto update_timer = Core::Timer::create_repeating(100, [&] { timer_label.set_text(String::formatted("{:.1} seconds", static_cast(clock.elapsed()) / 1000.0f).release_value_but_fixme_should_propagate_errors()); - }).release_value_but_fixme_should_propagate_errors(); + }); update_timer->start(); auto& stop_button = widget->add("Stop"_string); diff --git a/Userland/Games/Hearts/Game.cpp b/Userland/Games/Hearts/Game.cpp index 76315ff3ed6..f65618467dd 100644 --- a/Userland/Games/Hearts/Game.cpp +++ b/Userland/Games/Hearts/Game.cpp @@ -26,7 +26,7 @@ Game::Game() m_delay_timer = Core::Timer::create_single_shot(0, [this] { dbgln_if(HEARTS_DEBUG, "Continuing game after delay..."); advance_game(); - }).release_value_but_fixme_should_propagate_errors(); + }); constexpr int card_overlap = 20; constexpr int outer_border_size = 15; @@ -151,7 +151,7 @@ void Game::show_score_card(bool game_over) if (!m_players[0].is_human) { close_timer = Core::Timer::create_single_shot(2000, [&] { score_dialog->close(); - }).release_value_but_fixme_should_propagate_errors(); + }); close_timer->start(); } @@ -232,7 +232,7 @@ void Game::start_animation(Vector> cards, Gfx::IntPoint end, m_animation_delay_timer = Core::Timer::create_single_shot(initial_delay_ms, [&] { m_animation_playing = true; start_timer(10); - }).release_value_but_fixme_should_propagate_errors(); + }); m_animation_delay_timer->start(); } diff --git a/Userland/Games/MasterWord/WordGame.cpp b/Userland/Games/MasterWord/WordGame.cpp index f1897d092b2..d18a2149e54 100644 --- a/Userland/Games/MasterWord/WordGame.cpp +++ b/Userland/Games/MasterWord/WordGame.cpp @@ -22,7 +22,7 @@ namespace MasterWord { WordGame::WordGame() - : m_clear_message_timer(Core::Timer::create_single_shot(5000, [this] { clear_message(); }).release_value_but_fixme_should_propagate_errors()) + : m_clear_message_timer(Core::Timer::create_single_shot(5000, [this] { clear_message(); })) { read_words(); m_num_letters = Config::read_i32("MasterWord"sv, ""sv, "word_length"sv, 5); diff --git a/Userland/Games/Minesweeper/Field.cpp b/Userland/Games/Minesweeper/Field.cpp index 970fd0bba0f..930b2e38f51 100644 --- a/Userland/Games/Minesweeper/Field.cpp +++ b/Userland/Games/Minesweeper/Field.cpp @@ -140,8 +140,7 @@ void Field::initialize() ++m_time_elapsed; m_time_label.set_text(human_readable_digital_time(m_time_elapsed)); }, - this) - .release_value_but_fixme_should_propagate_errors(); + this); // Square with mine will be filled with background color later, i.e. red m_mine_palette.set_color(Gfx::ColorRole::Base, Color::from_rgb(0xff4040)); diff --git a/Userland/Games/Solitaire/main.cpp b/Userland/Games/Solitaire/main.cpp index 32ffb49eeac..de21814993b 100644 --- a/Userland/Games/Solitaire/main.cpp +++ b/Userland/Games/Solitaire/main.cpp @@ -121,10 +121,10 @@ ErrorOr serenity_main(Main::Arguments arguments) uint64_t seconds_elapsed = 0; - auto timer = TRY(Core::Timer::create_repeating(1000, [&]() { + auto timer = Core::Timer::create_repeating(1000, [&]() { ++seconds_elapsed; statusbar.set_text(2, String::formatted("Time: {}", human_readable_digital_time(seconds_elapsed)).release_value_but_fixme_should_propagate_errors()); - })); + }); game.on_game_start = [&]() { seconds_elapsed = 0; diff --git a/Userland/Games/Spider/main.cpp b/Userland/Games/Spider/main.cpp index 28087385aee..7160a09746c 100644 --- a/Userland/Games/Spider/main.cpp +++ b/Userland/Games/Spider/main.cpp @@ -154,11 +154,11 @@ ErrorOr serenity_main(Main::Arguments arguments) uint64_t seconds_elapsed = 0; - auto timer = TRY(Core::Timer::create_repeating(1000, [&]() { + auto timer = Core::Timer::create_repeating(1000, [&]() { ++seconds_elapsed; statusbar.set_text(2, String::formatted("Time: {}", human_readable_digital_time(seconds_elapsed)).release_value_but_fixme_should_propagate_errors()); - })); + }); game.on_game_start = [&]() { seconds_elapsed = 0; diff --git a/Userland/Libraries/LibAudio/PlaybackStreamSerenity.cpp b/Userland/Libraries/LibAudio/PlaybackStreamSerenity.cpp index c9fb0d1a254..4db05a32626 100644 --- a/Userland/Libraries/LibAudio/PlaybackStreamSerenity.cpp +++ b/Userland/Libraries/LibAudio/PlaybackStreamSerenity.cpp @@ -21,7 +21,7 @@ ErrorOr> PlaybackStreamSerenity::create(OutputStat if (auto result = connection->try_set_self_sample_rate(sample_rate); result.is_error()) return Error::from_string_literal("Failed to set sample rate"); - auto polling_timer = TRY(Core::Timer::try_create()); + auto polling_timer = Core::Timer::create(); auto implementation = TRY(adopt_nonnull_ref_or_enomem(new (nothrow) PlaybackStreamSerenity(connection, move(polling_timer), move(data_request_callback)))); if (initial_state == OutputState::Playing) connection->async_start_playback(); diff --git a/Userland/Libraries/LibCore/Debounce.h b/Userland/Libraries/LibCore/Debounce.h index 02dec51a61a..10b59efee33 100644 --- a/Userland/Libraries/LibCore/Debounce.h +++ b/Userland/Libraries/LibCore/Debounce.h @@ -20,7 +20,7 @@ auto debounce(int timeout, TFunction function) timer->stop(); timer->on_timeout = move(apply_function); } else { - timer = Core::Timer::create_single_shot(timeout, move(apply_function)).release_value_but_fixme_should_propagate_errors(); + timer = Core::Timer::create_single_shot(timeout, move(apply_function)); } timer->start(); }; diff --git a/Userland/Libraries/LibCore/Timer.cpp b/Userland/Libraries/LibCore/Timer.cpp index 15ed7dba538..734ffa08b94 100644 --- a/Userland/Libraries/LibCore/Timer.cpp +++ b/Userland/Libraries/LibCore/Timer.cpp @@ -9,6 +9,25 @@ namespace Core { +NonnullRefPtr Timer::create() +{ + return adopt_ref(*new Timer); +} + +NonnullRefPtr Timer::create_repeating(int interval_ms, Function&& timeout_handler, EventReceiver* parent) +{ + return adopt_ref(*new Timer(interval_ms, move(timeout_handler), parent)); +} + +NonnullRefPtr Timer::create_single_shot(int interval_ms, Function&& timeout_handler, EventReceiver* parent) +{ + auto timer = adopt_ref(*new Timer(interval_ms, move(timeout_handler), parent)); + timer->set_single_shot(true); + return timer; +} + +Timer::~Timer() = default; + Timer::Timer(EventReceiver* parent) : EventReceiver(parent) { diff --git a/Userland/Libraries/LibCore/Timer.h b/Userland/Libraries/LibCore/Timer.h index af3263d31e8..c990b41e277 100644 --- a/Userland/Libraries/LibCore/Timer.h +++ b/Userland/Libraries/LibCore/Timer.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018-2020, Andreas Kling + * Copyright (c) 2018-2024, Andreas Kling * Copyright (c) 2022, the SerenityOS developers. * * SPDX-License-Identifier: BSD-2-Clause @@ -16,18 +16,11 @@ class Timer final : public EventReceiver { C_OBJECT(Timer); public: - static ErrorOr> create_repeating(int interval_ms, Function&& timeout_handler, EventReceiver* parent = nullptr) - { - return adopt_nonnull_ref_or_enomem(new Timer(interval_ms, move(timeout_handler), parent)); - } - static ErrorOr> create_single_shot(int interval_ms, Function&& timeout_handler, EventReceiver* parent = nullptr) - { - auto timer = TRY(adopt_nonnull_ref_or_enomem(new Timer(interval_ms, move(timeout_handler), parent))); - timer->set_single_shot(true); - return timer; - } + 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); - virtual ~Timer() override = default; + virtual ~Timer() override; void start(); void start(int interval_ms); diff --git a/Userland/Libraries/LibGUI/Application.cpp b/Userland/Libraries/LibGUI/Application.cpp index 05d761bc83a..78aac1b8953 100644 --- a/Userland/Libraries/LibGUI/Application.cpp +++ b/Userland/Libraries/LibGUI/Application.cpp @@ -98,13 +98,13 @@ ErrorOr> Application::create(Main::Arguments const& a TRY(application->m_args.try_append(arg)); } - application->m_tooltip_show_timer = TRY(Core::Timer::create_single_shot(700, [weak_application = application->make_weak_ptr()] { + application->m_tooltip_show_timer = Core::Timer::create_single_shot(700, [weak_application = application->make_weak_ptr()] { weak_application->request_tooltip_show(); - })); + }); - application->m_tooltip_hide_timer = TRY(Core::Timer::create_single_shot(50, [weak_application = application->make_weak_ptr()] { + application->m_tooltip_hide_timer = Core::Timer::create_single_shot(50, [weak_application = application->make_weak_ptr()] { weak_application->tooltip_hide_timer_did_fire(); - })); + }); return application; } diff --git a/Userland/Libraries/LibGUI/TextEditor.cpp b/Userland/Libraries/LibGUI/TextEditor.cpp index 67561d60022..4f07411610d 100644 --- a/Userland/Libraries/LibGUI/TextEditor.cpp +++ b/Userland/Libraries/LibGUI/TextEditor.cpp @@ -2476,7 +2476,7 @@ void TextEditor::set_should_autocomplete_automatically(bool value) m_autocomplete_timer = Core::Timer::create_single_shot(m_automatic_autocomplete_delay_ms, [this] { if (m_autocomplete_box && !m_autocomplete_box->is_visible()) try_show_autocomplete(UserRequestedAutocomplete::No); - }).release_value_but_fixme_should_propagate_errors(); + }); return; } diff --git a/Userland/Libraries/LibIPC/Connection.cpp b/Userland/Libraries/LibIPC/Connection.cpp index e98f503c4f8..7355cd7cd35 100644 --- a/Userland/Libraries/LibIPC/Connection.cpp +++ b/Userland/Libraries/LibIPC/Connection.cpp @@ -27,7 +27,7 @@ ConnectionBase::ConnectionBase(IPC::Stub& local_stub, NonnullOwnPtr()) { - m_responsiveness_timer = Core::Timer::create_single_shot(3000, [this] { may_have_become_unresponsive(); }).release_value_but_fixme_should_propagate_errors(); + m_responsiveness_timer = Core::Timer::create_single_shot(3000, [this] { may_have_become_unresponsive(); }); } void ConnectionBase::set_deferred_invoker(NonnullOwnPtr deferred_invoker) diff --git a/Userland/Libraries/LibTLS/Socket.cpp b/Userland/Libraries/LibTLS/Socket.cpp index b11b2a1a600..90febf9928a 100644 --- a/Userland/Libraries/LibTLS/Socket.cpp +++ b/Userland/Libraries/LibTLS/Socket.cpp @@ -115,7 +115,7 @@ void TLSv12::setup_connection() // Extend the timer, we are too slow. m_handshake_timeout_timer->restart(m_max_wait_time_for_handshake_in_seconds * 1000); } - }).release_value_but_fixme_should_propagate_errors(); + }); auto packet = build_hello(); write_packet(packet); write_into_socket(); diff --git a/Userland/Libraries/LibVideo/PlaybackManager.cpp b/Userland/Libraries/LibVideo/PlaybackManager.cpp index 05ca12a620d..aac34df3043 100644 --- a/Userland/Libraries/LibVideo/PlaybackManager.cpp +++ b/Userland/Libraries/LibVideo/PlaybackManager.cpp @@ -66,7 +66,7 @@ DecoderErrorOr> PlaybackManager::create(NonnullOw auto frame_queue = DECODER_TRY_ALLOC(VideoFrameQueue::create()); auto playback_manager = DECODER_TRY_ALLOC(try_make(demuxer, track, move(decoder_non_null), move(frame_queue))); - playback_manager->m_state_update_timer = DECODER_TRY_ALLOC(Core::Timer::create_single_shot(0, [&self = *playback_manager] { self.timer_callback(); })); + playback_manager->m_state_update_timer = Core::Timer::create_single_shot(0, [&self = *playback_manager] { self.timer_callback(); }); playback_manager->m_decode_thread = DECODER_TRY_ALLOC(Threading::Thread::try_create([&self = *playback_manager] { while (!self.m_stop_decoding.load()) diff --git a/Userland/Libraries/LibWeb/DOM/Document.cpp b/Userland/Libraries/LibWeb/DOM/Document.cpp index 3e71b9febdb..161c93a0b69 100644 --- a/Userland/Libraries/LibWeb/DOM/Document.cpp +++ b/Userland/Libraries/LibWeb/DOM/Document.cpp @@ -3905,7 +3905,7 @@ void Document::shared_declarative_refresh_steps(StringView input, JS::GCPtrnavigate({ .url = url_record, .source_document = *this })); - }).release_value_but_fixme_should_propagate_errors(); + }); // For the purposes of the previous paragraph, a refresh is said to have come due as soon as the later of the // following two conditions occurs: @@ -4238,7 +4238,7 @@ void Document::ensure_animation_timer() { constexpr static auto timer_delay_ms = 1000 / 60; if (!m_animation_driver_timer) { - m_animation_driver_timer = MUST(Core::Timer::create_repeating(timer_delay_ms, [this] { + m_animation_driver_timer = Core::Timer::create_repeating(timer_delay_ms, [this] { bool has_animations = false; for (auto& timeline : m_associated_animation_timelines) { if (!timeline->associated_animations().is_empty()) { @@ -4253,7 +4253,7 @@ void Document::ensure_animation_timer() auto* window_or_worker = dynamic_cast(&realm().global_object()); VERIFY(window_or_worker); update_animations_and_send_events(window_or_worker->performance()->now()); - })); + }); } m_animation_driver_timer->start(); diff --git a/Userland/Libraries/LibWeb/HTML/AnimationFrameCallbackDriver.h b/Userland/Libraries/LibWeb/HTML/AnimationFrameCallbackDriver.h index cdc72292eba..4aaa423555c 100644 --- a/Userland/Libraries/LibWeb/HTML/AnimationFrameCallbackDriver.h +++ b/Userland/Libraries/LibWeb/HTML/AnimationFrameCallbackDriver.h @@ -19,9 +19,9 @@ struct AnimationFrameCallbackDriver { AnimationFrameCallbackDriver() { - m_timer = MUST(Core::Timer::create_single_shot(16, [] { + m_timer = Core::Timer::create_single_shot(16, [] { HTML::main_thread_event_loop().schedule(); - })); + }); } i32 add(Callback handler) diff --git a/Userland/Libraries/LibWeb/HTML/BrowsingContext.cpp b/Userland/Libraries/LibWeb/HTML/BrowsingContext.cpp index 0787e0abf80..bae2f29db49 100644 --- a/Userland/Libraries/LibWeb/HTML/BrowsingContext.cpp +++ b/Userland/Libraries/LibWeb/HTML/BrowsingContext.cpp @@ -291,7 +291,7 @@ BrowsingContext::BrowsingContext(JS::NonnullGCPtr page) m_cursor_blink_state = !m_cursor_blink_state; node->paintable()->set_needs_display(); } - }).release_value_but_fixme_should_propagate_errors(); + }); } BrowsingContext::~BrowsingContext() = default; diff --git a/Userland/Libraries/LibWeb/HTML/HTMLImageElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLImageElement.cpp index ab51a3ac8f2..b53772ede1a 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLImageElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLImageElement.cpp @@ -292,7 +292,7 @@ bool HTMLImageElement::uses_srcset_or_picture() const struct BatchingDispatcher { public: BatchingDispatcher() - : m_timer(Core::Timer::create_single_shot(1, [this] { process(); }).release_value_but_fixme_should_propagate_errors()) + : m_timer(Core::Timer::create_single_shot(1, [this] { process(); })) { } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLTextAreaElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLTextAreaElement.cpp index e9e52217800..81be3f122b4 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLTextAreaElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLTextAreaElement.cpp @@ -26,11 +26,11 @@ JS_DEFINE_ALLOCATOR(HTMLTextAreaElement); HTMLTextAreaElement::HTMLTextAreaElement(DOM::Document& document, DOM::QualifiedName qualified_name) : HTMLElement(document, move(qualified_name)) - , m_input_event_timer(MUST(Core::Timer::create_single_shot(0, [weak_this = make_weak_ptr()]() { + , m_input_event_timer(Core::Timer::create_single_shot(0, [weak_this = make_weak_ptr()]() { if (!weak_this) return; static_cast(weak_this.ptr())->queue_firing_input_event(); - }))) + })) { } diff --git a/Userland/Libraries/LibWeb/HTML/SessionHistoryTraversalQueue.cpp b/Userland/Libraries/LibWeb/HTML/SessionHistoryTraversalQueue.cpp index 6d3b619c21f..3914bfa9c00 100644 --- a/Userland/Libraries/LibWeb/HTML/SessionHistoryTraversalQueue.cpp +++ b/Userland/Libraries/LibWeb/HTML/SessionHistoryTraversalQueue.cpp @@ -37,7 +37,7 @@ SessionHistoryTraversalQueue::SessionHistoryTraversalQueue() entry->execute_steps(); m_is_task_running = false; } - }).release_value_but_fixme_should_propagate_errors(); + }); } void SessionHistoryTraversalQueue::visit_edges(JS::Cell::Visitor& visitor) diff --git a/Userland/Libraries/LibWeb/HTML/Timer.cpp b/Userland/Libraries/LibWeb/HTML/Timer.cpp index d2e79ec64dd..1161b48051a 100644 --- a/Userland/Libraries/LibWeb/HTML/Timer.cpp +++ b/Userland/Libraries/LibWeb/HTML/Timer.cpp @@ -26,7 +26,7 @@ Timer::Timer(JS::Object& window_or_worker_global_scope, i32 milliseconds, JS::No { m_timer = Core::Timer::create_single_shot(milliseconds, [this] { m_callback->function()(); - }).release_value_but_fixme_should_propagate_errors(); + }); } void Timer::visit_edges(Cell::Visitor& visitor) diff --git a/Userland/Libraries/LibWeb/Platform/AudioCodecPluginAgnostic.cpp b/Userland/Libraries/LibWeb/Platform/AudioCodecPluginAgnostic.cpp index ad72665d325..0f50d1b9966 100644 --- a/Userland/Libraries/LibWeb/Platform/AudioCodecPluginAgnostic.cpp +++ b/Userland/Libraries/LibWeb/Platform/AudioCodecPluginAgnostic.cpp @@ -31,7 +31,7 @@ ErrorOr> AudioCodecPluginAgnostic::creat { auto duration = timestamp_from_samples(loader->total_samples(), loader->sample_rate()); - auto update_timer = TRY(Core::Timer::try_create()); + auto update_timer = Core::Timer::create(); update_timer->set_interval(update_interval); auto plugin = TRY(adopt_nonnull_own_or_enomem(new (nothrow) AudioCodecPluginAgnostic(loader, duration, move(update_timer)))); diff --git a/Userland/Libraries/LibWebView/ViewImplementation.cpp b/Userland/Libraries/LibWebView/ViewImplementation.cpp index 2d97a817dd7..c70a91bc106 100644 --- a/Userland/Libraries/LibWebView/ViewImplementation.cpp +++ b/Userland/Libraries/LibWebView/ViewImplementation.cpp @@ -18,13 +18,13 @@ ViewImplementation::ViewImplementation() { m_backing_store_shrink_timer = Core::Timer::create_single_shot(3000, [this] { resize_backing_stores_if_needed(WindowResizeInProgress::No); - }).release_value_but_fixme_should_propagate_errors(); + }); m_repeated_crash_timer = Core::Timer::create_single_shot(1000, [this] { // Reset the "crashing a lot" counter after 1 second in case we just // happen to be visiting crashy websites a lot. this->m_crash_count = 0; - }).release_value_but_fixme_should_propagate_errors(); + }); on_request_file = [this](auto const& path, auto request_id) { auto file = Core::File::open(path, Core::File::OpenMode::Read); diff --git a/Userland/Services/AudioServer/Mixer.cpp b/Userland/Services/AudioServer/Mixer.cpp index f9bddc76803..9138c010443 100644 --- a/Userland/Services/AudioServer/Mixer.cpp +++ b/Userland/Services/AudioServer/Mixer.cpp @@ -183,8 +183,7 @@ void Mixer::request_setting_sync() if (auto result = m_config->sync(); result.is_error()) dbgln("Failed to write audio mixer config: {}", result.error()); }, - this) - .release_value_but_fixme_should_propagate_errors(); + this); m_config_write_timer->start(); } } diff --git a/Userland/Services/ConfigServer/ConnectionFromClient.cpp b/Userland/Services/ConfigServer/ConnectionFromClient.cpp index 38104ff96e7..b41ffdcc25f 100644 --- a/Userland/Services/ConfigServer/ConnectionFromClient.cpp +++ b/Userland/Services/ConfigServer/ConnectionFromClient.cpp @@ -76,7 +76,7 @@ static Core::ConfigFile& ensure_domain_config(ByteString const& domain) ConnectionFromClient::ConnectionFromClient(NonnullOwnPtr client_socket, int client_id) : IPC::ConnectionFromClient(*this, move(client_socket), client_id) - , m_sync_timer(Core::Timer::create_single_shot(s_disk_sync_delay_ms, [this]() { sync_dirty_domains_to_disk(); }).release_value_but_fixme_should_propagate_errors()) + , m_sync_timer(Core::Timer::create_single_shot(s_disk_sync_delay_ms, [this]() { sync_dirty_domains_to_disk(); })) { s_connections.set(client_id, *this); } diff --git a/Userland/Services/DHCPClient/DHCPv4Client.cpp b/Userland/Services/DHCPClient/DHCPv4Client.cpp index 77499b5c138..94072b5e89b 100644 --- a/Userland/Services/DHCPClient/DHCPv4Client.cpp +++ b/Userland/Services/DHCPClient/DHCPv4Client.cpp @@ -144,8 +144,7 @@ DHCPv4Client::DHCPv4Client(Vector interfaces_with_dhcp_enabled) } m_check_timer = Core::Timer::create_repeating( - 1000, [this] { try_discover_ifs(); }, this) - .release_value_but_fixme_should_propagate_errors(); + 1000, [this] { try_discover_ifs(); }, this); m_check_timer->start(); @@ -266,8 +265,7 @@ void DHCPv4Client::handle_ack(DHCPv4Packet const& packet, ParsedDHCPv4Options co transaction->has_ip = false; dhcp_discover(interface); }, - this) - .release_value_but_fixme_should_propagate_errors(); + this); Optional gateway; if (auto routers = options.get_many(DHCPOption::Router, 1); !routers.is_empty()) @@ -294,8 +292,7 @@ void DHCPv4Client::handle_nak(DHCPv4Packet const& packet, ParsedDHCPv4Options co [this, iface = InterfaceDescriptor { iface }] { dhcp_discover(iface); }, - this) - .release_value_but_fixme_should_propagate_errors(); + this); } void DHCPv4Client::process_incoming(DHCPv4Packet const& packet) diff --git a/Userland/Services/RequestServer/ConnectionCache.h b/Userland/Services/RequestServer/ConnectionCache.h index 2e0c8b15ddf..9ebe6cb27f9 100644 --- a/Userland/Services/RequestServer/ConnectionCache.h +++ b/Userland/Services/RequestServer/ConnectionCache.h @@ -217,7 +217,7 @@ decltype(auto) get_or_create_connection(auto& cache, URL::URL const& url, auto j sockets_for_url.append(make( socket_result.release_value(), typename ConnectionType::QueueType {}, - Core::Timer::create_single_shot(ConnectionKeepAliveTimeMilliseconds, nullptr).release_value_but_fixme_should_propagate_errors())); + Core::Timer::create_single_shot(ConnectionKeepAliveTimeMilliseconds, nullptr))); sockets_for_url.last()->proxy = move(proxy); did_add_new_connection = true; } diff --git a/Userland/Services/WindowServer/Compositor.cpp b/Userland/Services/WindowServer/Compositor.cpp index 847c3483c81..492bd260d33 100644 --- a/Userland/Services/WindowServer/Compositor.cpp +++ b/Userland/Services/WindowServer/Compositor.cpp @@ -56,8 +56,7 @@ Compositor::Compositor() [this] { compose(); }, - this) - .release_value_but_fixme_should_propagate_errors(); + this); m_compose_timer->start(); m_immediate_compose_timer = Core::Timer::create_single_shot( @@ -65,8 +64,7 @@ Compositor::Compositor() [this] { compose(); }, - this) - .release_value_but_fixme_should_propagate_errors(); + this); m_compose_timer->start(); init_bitmaps(); @@ -1626,8 +1624,7 @@ void Compositor::start_window_stack_switch_overlay_timer() [this] { remove_window_stack_switch_overlays(); }, - this) - .release_value_but_fixme_should_propagate_errors(); + this); m_stack_switch_overlay_timer->start(); } diff --git a/Userland/Services/WindowServer/ConnectionFromClient.cpp b/Userland/Services/WindowServer/ConnectionFromClient.cpp index d67a97a8533..f40bf874a9f 100644 --- a/Userland/Services/WindowServer/ConnectionFromClient.cpp +++ b/Userland/Services/WindowServer/ConnectionFromClient.cpp @@ -280,7 +280,7 @@ void ConnectionFromClient::flash_menubar_menu(i32 window_id, i32 menu_id) return; weak_window->menubar().flash_menu(nullptr); weak_window->frame().invalidate_menubar(); - }).release_value_but_fixme_should_propagate_errors(); + }); m_flashed_menu_timer->start(); } else if (m_flashed_menu_timer) { m_flashed_menu_timer->restart(); @@ -1186,7 +1186,7 @@ void ConnectionFromClient::may_have_become_unresponsive() async_ping(); m_ping_timer = Core::Timer::create_single_shot(1000, [this] { set_unresponsive(true); - }).release_value_but_fixme_should_propagate_errors(); + }); m_ping_timer->start(); } diff --git a/Userland/Services/WindowServer/Menu.cpp b/Userland/Services/WindowServer/Menu.cpp index 738728398f2..6d7dbb24ff0 100644 --- a/Userland/Services/WindowServer/Menu.cpp +++ b/Userland/Services/WindowServer/Menu.cpp @@ -551,7 +551,7 @@ void Menu::start_activation_animation(MenuItem& item) painter.clear_rect({ {}, animation->window->rect().size() }, Color::Transparent); painter.blit({}, original_bitmap, item_rect, opacity, true); animation->window->invalidate(); - }).release_value_but_fixme_should_propagate_errors(); + }); timer->start(); } diff --git a/Userland/Services/WindowServer/WindowFrame.cpp b/Userland/Services/WindowServer/WindowFrame.cpp index 9909708988f..e0fbddf529f 100644 --- a/Userland/Services/WindowServer/WindowFrame.cpp +++ b/Userland/Services/WindowServer/WindowFrame.cpp @@ -946,7 +946,7 @@ void WindowFrame::start_flash_animation() invalidate_titlebar(); if (!--m_flash_counter) m_flash_timer->stop(); - }).release_value_but_fixme_should_propagate_errors(); + }); } m_flash_counter = 8; m_flash_timer->start(); diff --git a/Userland/Shell/Shell.cpp b/Userland/Shell/Shell.cpp index af25f898c7a..7911ddf7376 100644 --- a/Userland/Shell/Shell.cpp +++ b/Userland/Shell/Shell.cpp @@ -2005,9 +2005,9 @@ ErrorOr> Shell::complete_via_program_itself(s true); Vector suggestions; - auto timer = TRY(Core::Timer::create_single_shot(300, [&] { + auto timer = Core::Timer::create_single_shot(300, [&] { Core::EventLoop::current().quit(1); - })); + }); timer->start(); // Restrict the process to effectively readonly access to the FS. diff --git a/Userland/Utilities/headless-browser.cpp b/Userland/Utilities/headless-browser.cpp index b6af805de89..db637e952be 100644 --- a/Userland/Utilities/headless-browser.cpp +++ b/Userland/Utilities/headless-browser.cpp @@ -218,7 +218,7 @@ static ErrorOr> load_page_for_screenshot_and_exit(Cor outln("Taking screenshot after {} seconds", screenshot_timeout); - auto timer = TRY(Core::Timer::create_single_shot( + auto timer = Core::Timer::create_single_shot( screenshot_timeout * 1000, [&]() { if (auto screenshot = view.take_screenshot()) { @@ -232,7 +232,7 @@ static ErrorOr> load_page_for_screenshot_and_exit(Cor } event_loop.quit(0); - })); + }); view.load(url); timer->start(); @@ -272,10 +272,10 @@ static ErrorOr run_dump_test(HeadlessWebContentView& view, StringVie Core::EventLoop loop; bool did_timeout = false; - auto timeout_timer = TRY(Core::Timer::create_single_shot(timeout_in_milliseconds, [&] { + auto timeout_timer = Core::Timer::create_single_shot(timeout_in_milliseconds, [&] { did_timeout = true; loop.quit(0); - })); + }); auto url = URL::create_with_file_scheme(TRY(FileSystem::real_path(input_path))); @@ -373,10 +373,10 @@ static ErrorOr run_ref_test(HeadlessWebContentView& view, StringView Core::EventLoop loop; bool did_timeout = false; - auto timeout_timer = TRY(Core::Timer::create_single_shot(timeout_in_milliseconds, [&] { + auto timeout_timer = Core::Timer::create_single_shot(timeout_in_milliseconds, [&] { did_timeout = true; loop.quit(0); - })); + }); RefPtr actual_screenshot, expectation_screenshot; view.on_load_finish = [&](auto const&) {