mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 16:32:45 +00:00 
			
		
		
		
	LibCore+Userland: Make Core::Timer::create_repeating() return ErrorOr
The FIXMEs must flow!
This commit is contained in:
		
							parent
							
								
									1d4f287582
								
							
						
					
					
						commit
						a15d44f019
					
				
					 12 changed files with 19 additions and 17 deletions
				
			
		|  | @ -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(); | ||||
| } | ||||
|  |  | |||
|  | @ -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.
 | ||||
|  |  | |||
|  | @ -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; | ||||
|  |  | |||
|  | @ -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(); | ||||
| } | ||||
| 
 | ||||
|  |  | |||
|  | @ -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) { | ||||
|  |  | |||
|  | @ -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(); | ||||
| } | ||||
| 
 | ||||
|  |  | |||
|  | @ -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)); | ||||
|  |  | |||
|  | @ -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; | ||||
|  |  | |||
|  | @ -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; | ||||
|  |  | |||
|  | @ -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; | ||||
|     } | ||||
|  |  | |||
|  | @ -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(); | ||||
| 
 | ||||
|  |  | |||
|  | @ -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(); | ||||
| } | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Sam Atkins
						Sam Atkins