diff --git a/Userland/Applications/SoundPlayer/PlaybackManager.cpp b/Userland/Applications/SoundPlayer/PlaybackManager.cpp index aa1830e2d3..e929cf144d 100644 --- a/Userland/Applications/SoundPlayer/PlaybackManager.cpp +++ b/Userland/Applications/SoundPlayer/PlaybackManager.cpp @@ -16,7 +16,6 @@ PlaybackManager::PlaybackManager(NonnullRefPtr connec return; next_buffer(); }); - m_timer->stop(); m_device_sample_rate = connection->get_sample_rate(); } diff --git a/Userland/Applications/SystemMonitor/NetworkStatisticsWidget.cpp b/Userland/Applications/SystemMonitor/NetworkStatisticsWidget.cpp index 057fbf1978..f99b3ecd3a 100644 --- a/Userland/Applications/SystemMonitor/NetworkStatisticsWidget.cpp +++ b/Userland/Applications/SystemMonitor/NetworkStatisticsWidget.cpp @@ -132,6 +132,7 @@ NetworkStatisticsWidget::NetworkStatisticsWidget() 1000, [this] { update_models(); }); + m_update_timer->start(); update_models(); }; diff --git a/Userland/Applications/SystemMonitor/ProcessMemoryMapWidget.cpp b/Userland/Applications/SystemMonitor/ProcessMemoryMapWidget.cpp index 495ad362cf..a83d31b47a 100644 --- a/Userland/Applications/SystemMonitor/ProcessMemoryMapWidget.cpp +++ b/Userland/Applications/SystemMonitor/ProcessMemoryMapWidget.cpp @@ -110,6 +110,7 @@ ProcessMemoryMapWidget::ProcessMemoryMapWidget() m_table_view->set_key_column_and_sort_order(0, GUI::SortOrder::Ascending); m_timer = add(1000, [this] { refresh(); }); + m_timer->start(); } void ProcessMemoryMapWidget::set_pid(pid_t pid) diff --git a/Userland/Applications/SystemMonitor/ThreadStackWidget.cpp b/Userland/Applications/SystemMonitor/ThreadStackWidget.cpp index c560299365..4f14651bc0 100644 --- a/Userland/Applications/SystemMonitor/ThreadStackWidget.cpp +++ b/Userland/Applications/SystemMonitor/ThreadStackWidget.cpp @@ -82,8 +82,10 @@ ThreadStackWidget::ThreadStackWidget() void ThreadStackWidget::show_event(GUI::ShowEvent&) { refresh(); - if (!m_timer) + if (!m_timer) { m_timer = add(1000, [this] { refresh(); }); + m_timer->start(); + } } void ThreadStackWidget::hide_event(GUI::HideEvent&) diff --git a/Userland/Applications/SystemMonitor/main.cpp b/Userland/Applications/SystemMonitor/main.cpp index e01aa4f254..e1b110d38c 100644 --- a/Userland/Applications/SystemMonitor/main.cpp +++ b/Userland/Applications/SystemMonitor/main.cpp @@ -328,6 +328,7 @@ ErrorOr serenity_main(Main::Arguments arguments) }; update_stats(); auto& refresh_timer = window->add(frequency * 1000, move(update_stats)); + refresh_timer.start(); auto selected_id = [&](ProcessModel::Column column) -> pid_t { if (process_table_view.selection().is_empty()) diff --git a/Userland/DevTools/Profiler/main.cpp b/Userland/DevTools/Profiler/main.cpp index 431b09d7fa..5660ed4a0d 100644 --- a/Userland/DevTools/Profiler/main.cpp +++ b/Userland/DevTools/Profiler/main.cpp @@ -329,6 +329,7 @@ static bool prompt_to_stop_profiling(pid_t pid, DeprecatedString const& process_ auto update_timer = Core::Timer::construct(100, [&] { timer_label.set_text(DeprecatedString::formatted("{:.1} seconds", static_cast(clock.elapsed()) / 1000.0f)); }); + update_timer->start(); auto& stop_button = widget->add("Stop"); stop_button.set_fixed_size(140, 22); diff --git a/Userland/Libraries/LibCore/Timer.cpp b/Userland/Libraries/LibCore/Timer.cpp index 1942a262a4..2099eee9af 100644 --- a/Userland/Libraries/LibCore/Timer.cpp +++ b/Userland/Libraries/LibCore/Timer.cpp @@ -17,8 +17,8 @@ Timer::Timer(Object* parent) Timer::Timer(int interval_ms, Function&& timeout_handler, Object* parent) : Object(parent) , on_timeout(move(timeout_handler)) + , m_interval_ms(interval_ms) { - start(interval_ms); } void Timer::start() diff --git a/Userland/Libraries/LibCore/Timer.h b/Userland/Libraries/LibCore/Timer.h index 043fb21f42..63c3c06d7c 100644 --- a/Userland/Libraries/LibCore/Timer.h +++ b/Userland/Libraries/LibCore/Timer.h @@ -18,15 +18,12 @@ class Timer final : public Object { public: static ErrorOr> create_repeating(int interval_ms, Function&& 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> create_single_shot(int interval_ms, Function&& 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; } diff --git a/Userland/Services/Taskbar/ClockWidget.cpp b/Userland/Services/Taskbar/ClockWidget.cpp index 12e7f299df..60088cbd95 100644 --- a/Userland/Services/Taskbar/ClockWidget.cpp +++ b/Userland/Services/Taskbar/ClockWidget.cpp @@ -35,6 +35,7 @@ ClockWidget::ClockWidget() set_tooltip(Core::DateTime::now().to_deprecated_string("%Y-%m-%d"sv)); } }); + m_timer->start(); m_calendar_window = add(window()); m_calendar_window->set_window_type(GUI::WindowType::Popup); diff --git a/Userland/Services/WindowServer/Compositor.cpp b/Userland/Services/WindowServer/Compositor.cpp index cbc49093f2..862d66ccf7 100644 --- a/Userland/Services/WindowServer/Compositor.cpp +++ b/Userland/Services/WindowServer/Compositor.cpp @@ -48,7 +48,6 @@ Compositor::Compositor() 1000 / 60, [this] { notify_display_links(); }); - m_display_link_notify_timer->stop(); m_compose_timer = Core::Timer::create_single_shot( 1000 / 60, @@ -57,6 +56,7 @@ Compositor::Compositor() }, this) .release_value_but_fixme_should_propagate_errors(); + m_compose_timer->start(); m_immediate_compose_timer = Core::Timer::create_single_shot( 0, @@ -65,6 +65,7 @@ Compositor::Compositor() }, this) .release_value_but_fixme_should_propagate_errors(); + m_compose_timer->start(); init_bitmaps(); }