diff --git a/Libraries/LibWebView/Application.cpp b/Libraries/LibWebView/Application.cpp index b72a2290951..8f52a278210 100644 --- a/Libraries/LibWebView/Application.cpp +++ b/Libraries/LibWebView/Application.cpp @@ -56,28 +56,6 @@ Application::Application(Optional ladybird_binary_path) VERIFY(!s_the); s_the = this; - m_settings_observer = make(); - - // No need to monitor the system time zone if the TZ environment variable is set, as it overrides system preferences. - if (!Core::Environment::has("TZ"sv)) { - if (auto time_zone_watcher = Core::TimeZoneWatcher::create(); time_zone_watcher.is_error()) { - warnln("Unable to monitor system time zone: {}", time_zone_watcher.error()); - } else { - m_time_zone_watcher = time_zone_watcher.release_value(); - - m_time_zone_watcher->on_time_zone_changed = []() { - WebContentClient::for_each_client([&](WebView::WebContentClient& client) { - client.async_system_time_zone_changed(); - return IterationDecision::Continue; - }); - }; - } - } - - m_process_manager.on_process_exited = [this](Process&& process) { - process_did_exit(move(process)); - }; - platform_init(move(ladybird_binary_path)); } @@ -336,6 +314,13 @@ void Application::launch_spare_web_content_process() ErrorOr Application::launch_services() { + m_settings_observer = make(); + + m_process_manager = make(); + m_process_manager->on_process_exited = [this](Process&& process) { + process_did_exit(move(process)); + }; + if (m_browser_options.disable_sql_database == DisableSQLDatabase::No) { m_database = Database::create().release_value_but_fixme_should_propagate_errors(); m_cookie_jar = CookieJar::create(*m_database).release_value_but_fixme_should_propagate_errors(); @@ -343,6 +328,22 @@ ErrorOr Application::launch_services() m_cookie_jar = CookieJar::create(); } + // No need to monitor the system time zone if the TZ environment variable is set, as it overrides system preferences. + if (!Core::Environment::has("TZ"sv)) { + if (auto time_zone_watcher = Core::TimeZoneWatcher::create(); time_zone_watcher.is_error()) { + warnln("Unable to monitor system time zone: {}", time_zone_watcher.error()); + } else { + m_time_zone_watcher = time_zone_watcher.release_value(); + + m_time_zone_watcher->on_time_zone_changed = []() { + WebContentClient::for_each_client([&](WebView::WebContentClient& client) { + client.async_system_time_zone_changed(); + return IterationDecision::Continue; + }); + }; + } + } + TRY(launch_request_server()); TRY(launch_image_decoder_server()); return {}; @@ -476,19 +477,19 @@ NonnullOwnPtr Application::create_platform_event_loop() void Application::add_child_process(WebView::Process&& process) { - m_process_manager.add_process(move(process)); + m_process_manager->add_process(move(process)); } #if defined(AK_OS_MACH) void Application::set_process_mach_port(pid_t pid, Core::MachPort&& port) { - m_process_manager.set_process_mach_port(pid, move(port)); + m_process_manager->set_process_mach_port(pid, move(port)); } #endif Optional Application::find_process(pid_t pid) { - return m_process_manager.find_process(pid); + return m_process_manager->find_process(pid); } void Application::process_did_exit(Process&& process) diff --git a/Libraries/LibWebView/Application.h b/Libraries/LibWebView/Application.h index c1921b36520..ac3ea0e7057 100644 --- a/Libraries/LibWebView/Application.h +++ b/Libraries/LibWebView/Application.h @@ -47,7 +47,7 @@ public: static CookieJar& cookie_jar() { return *the().m_cookie_jar; } - static ProcessManager& process_manager() { return the().m_process_manager; } + static ProcessManager& process_manager() { return *the().m_process_manager; } ErrorOr> launch_web_content_process(ViewImplementation&); @@ -142,7 +142,7 @@ private: OwnPtr m_time_zone_watcher; OwnPtr m_event_loop; - ProcessManager m_process_manager; + OwnPtr m_process_manager; bool m_in_shutdown { false }; #if defined(AK_OS_MACOS) diff --git a/UI/Qt/Application.cpp b/UI/Qt/Application.cpp index 04b156f0484..19d498901da 100644 --- a/UI/Qt/Application.cpp +++ b/UI/Qt/Application.cpp @@ -59,8 +59,8 @@ void Application::create_platform_options(WebView::BrowserOptions&, WebView::Web NonnullOwnPtr Application::create_platform_event_loop() { if (!browser_options().headless_mode.has_value()) { - m_application = make(arguments()); Core::EventLoopManager::install(*new WebView::EventLoopManagerQt); + m_application = make(arguments()); } auto event_loop = WebView::Application::create_platform_event_loop();