diff options
author | Sam Atkins <atkinssj@serenityos.org> | 2023-01-11 16:20:17 +0000 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2023-01-12 11:25:51 +0100 |
commit | a15d44f019dc60b001c565ce0b940cc87024dbfd (patch) | |
tree | 173e3568bff54713fbe7444fd20eada916287f5e /Userland | |
parent | 1d4f287582f43acfd76661d20bc2915455809f41 (diff) | |
download | serenity-a15d44f019dc60b001c565ce0b940cc87024dbfd.zip |
LibCore+Userland: Make Core::Timer::create_repeating() return ErrorOr
The FIXMEs must flow!
Diffstat (limited to 'Userland')
-rw-r--r-- | Userland/Applications/ClockSettings/ClockSettingsWidget.cpp | 2 | ||||
-rw-r--r-- | Userland/Applications/DisplaySettings/MonitorSettingsWidget.cpp | 2 | ||||
-rw-r--r-- | Userland/Applications/MouseSettings/HighlightPreviewWidget.cpp | 4 | ||||
-rw-r--r-- | Userland/Applications/PixelPaint/ImageEditor.cpp | 2 | ||||
-rw-r--r-- | Userland/Applications/Terminal/main.cpp | 4 | ||||
-rw-r--r-- | Userland/DevTools/HackStudio/Editor.cpp | 2 | ||||
-rw-r--r-- | Userland/Games/Minesweeper/Field.cpp | 3 | ||||
-rw-r--r-- | Userland/Games/Solitaire/main.cpp | 4 | ||||
-rw-r--r-- | Userland/Games/Spider/main.cpp | 4 | ||||
-rw-r--r-- | Userland/Libraries/LibCore/Timer.h | 4 | ||||
-rw-r--r-- | Userland/Services/DHCPClient/DHCPv4Client.cpp | 3 | ||||
-rw-r--r-- | Userland/Services/WindowServer/Menu.cpp | 2 |
12 files changed, 19 insertions, 17 deletions
diff --git a/Userland/Applications/ClockSettings/ClockSettingsWidget.cpp b/Userland/Applications/ClockSettings/ClockSettingsWidget.cpp index e91ca92829..665db476bb 100644 --- a/Userland/Applications/ClockSettings/ClockSettingsWidget.cpp +++ b/Userland/Applications/ClockSettings/ClockSettingsWidget.cpp @@ -89,7 +89,7 @@ ClockSettingsWidget::ClockSettingsWidget() m_clock_preview_update_timer = Core::Timer::create_repeating(1000, [&]() { update_clock_preview(); - }); + }).release_value_but_fixme_should_propagate_errors(); m_clock_preview_update_timer->start(); update_clock_preview(); } diff --git a/Userland/Applications/DisplaySettings/MonitorSettingsWidget.cpp b/Userland/Applications/DisplaySettings/MonitorSettingsWidget.cpp index 13760c204e..df59e5c55f 100644 --- a/Userland/Applications/DisplaySettings/MonitorSettingsWidget.cpp +++ b/Userland/Applications/DisplaySettings/MonitorSettingsWidget.cpp @@ -250,7 +250,7 @@ void MonitorSettingsWidget::apply_settings() if (seconds_until_revert <= 0) { box->close(); } - }); + }).release_value_but_fixme_should_propagate_errors(); 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 8501aceba4..7699d29725 100644 --- a/Userland/Applications/MouseSettings/HighlightPreviewWidget.cpp +++ b/Userland/Applications/MouseSettings/HighlightPreviewWidget.cpp @@ -37,10 +37,10 @@ ErrorOr<void> 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 = Core::Timer::create_repeating(m_cursor_params.frame_ms(), [&] { + m_frame_timer = TRY(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/PixelPaint/ImageEditor.cpp b/Userland/Applications/PixelPaint/ImageEditor.cpp index 6a61f7b23b..23096e2b6e 100644 --- a/Userland/Applications/PixelPaint/ImageEditor.cpp +++ b/Userland/Applications/PixelPaint/ImageEditor.cpp @@ -51,7 +51,7 @@ ImageEditor::ImageEditor(NonnullRefPtr<Image> 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/Terminal/main.cpp b/Userland/Applications/Terminal/main.cpp index 4a8289a810..681e9c5b81 100644 --- a/Userland/Applications/Terminal/main.cpp +++ b/Userland/Applications/Terminal/main.cpp @@ -453,9 +453,9 @@ ErrorOr<int> 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 = Core::Timer::create_repeating(500, [&] { + auto modified_state_check_timer = TRY(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/DevTools/HackStudio/Editor.cpp b/Userland/DevTools/HackStudio/Editor.cpp index 6d214a6191..c119c2a42f 100644 --- a/Userland/DevTools/HackStudio/Editor.cpp +++ b/Userland/DevTools/HackStudio/Editor.cpp @@ -786,7 +786,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/Games/Minesweeper/Field.cpp b/Userland/Games/Minesweeper/Field.cpp index 54cc812394..eaf050ed79 100644 --- a/Userland/Games/Minesweeper/Field.cpp +++ b/Userland/Games/Minesweeper/Field.cpp @@ -140,7 +140,8 @@ void Field::initialize() ++m_time_elapsed; m_time_label.set_text(human_readable_digital_time(m_time_elapsed)); }, - this); + this) + .release_value_but_fixme_should_propagate_errors(); // 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 62a3bc3adf..d56a978870 100644 --- a/Userland/Games/Solitaire/main.cpp +++ b/Userland/Games/Solitaire/main.cpp @@ -111,7 +111,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) uint64_t seconds_elapsed = 0; - auto timer = Core::Timer::create_repeating(1000, [&]() { + auto timer = TRY(Core::Timer::create_repeating(1000, [&]() { ++seconds_elapsed; uint64_t hours = seconds_elapsed / 3600; @@ -119,7 +119,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) uint64_t seconds = seconds_elapsed % 60; statusbar.set_text(2, DeprecatedString::formatted("Time: {:02}:{:02}:{:02}", hours, minutes, seconds)); - }); + })); game.on_game_start = [&]() { seconds_elapsed = 0; diff --git a/Userland/Games/Spider/main.cpp b/Userland/Games/Spider/main.cpp index 2c0d0e81b8..65b2603202 100644 --- a/Userland/Games/Spider/main.cpp +++ b/Userland/Games/Spider/main.cpp @@ -158,11 +158,11 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) uint64_t seconds_elapsed = 0; - auto timer = Core::Timer::create_repeating(1000, [&]() { + auto timer = TRY(Core::Timer::create_repeating(1000, [&]() { ++seconds_elapsed; statusbar.set_text(2, DeprecatedString::formatted("Time: {}", format_seconds(seconds_elapsed))); - }); + })); game.on_game_start = [&]() { seconds_elapsed = 0; diff --git a/Userland/Libraries/LibCore/Timer.h b/Userland/Libraries/LibCore/Timer.h index b41caa4f54..23a59794db 100644 --- a/Userland/Libraries/LibCore/Timer.h +++ b/Userland/Libraries/LibCore/Timer.h @@ -16,9 +16,9 @@ class Timer final : public Object { C_OBJECT(Timer); public: - static NonnullRefPtr<Timer> create_repeating(int interval_ms, Function<void()>&& timeout_handler, Object* parent = nullptr) + static ErrorOr<NonnullRefPtr<Timer>> create_repeating(int interval_ms, Function<void()>&& timeout_handler, Object* parent = nullptr) { - auto timer = adopt_ref(*new Timer(interval_ms, move(timeout_handler), parent)); + auto timer = TRY(adopt_nonnull_ref_or_enomem(new Timer(interval_ms, move(timeout_handler), parent))); timer->stop(); return timer; } diff --git a/Userland/Services/DHCPClient/DHCPv4Client.cpp b/Userland/Services/DHCPClient/DHCPv4Client.cpp index 8d2d4c4231..20f3c89f99 100644 --- a/Userland/Services/DHCPClient/DHCPv4Client.cpp +++ b/Userland/Services/DHCPClient/DHCPv4Client.cpp @@ -139,7 +139,8 @@ DHCPv4Client::DHCPv4Client(Vector<DeprecatedString> interfaces_with_dhcp_enabled } m_check_timer = Core::Timer::create_repeating( - 1000, [this] { try_discover_ifs(); }, this); + 1000, [this] { try_discover_ifs(); }, this) + .release_value_but_fixme_should_propagate_errors(); m_check_timer->start(); diff --git a/Userland/Services/WindowServer/Menu.cpp b/Userland/Services/WindowServer/Menu.cpp index 83048cab5c..376009c3f1 100644 --- a/Userland/Services/WindowServer/Menu.cpp +++ b/Userland/Services/WindowServer/Menu.cpp @@ -537,7 +537,7 @@ void Menu::start_activation_animation(MenuItem& item) float opacity = (float)animation->step / 10.0f; animation->window->set_opacity(opacity); - }); + }).release_value_but_fixme_should_propagate_errors(); timer->start(); } |