From 5f76776f479846e3173db719cbbfc11049bbca6f Mon Sep 17 00:00:00 2001 From: johndoe6345789 Date: Sun, 4 Jan 2026 13:54:56 +0000 Subject: [PATCH] feat: Re-enable service initialization in ServiceBasedApp and improve SDL initialization check in SdlWindowService --- src/app/service_based_app.cpp | 3 +-- src/services/impl/sdl_window_service.cpp | 17 +++++++++++------ 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/app/service_based_app.cpp b/src/app/service_based_app.cpp index f864995..2765d0d 100644 --- a/src/app/service_based_app.cpp +++ b/src/app/service_based_app.cpp @@ -54,8 +54,7 @@ void ServiceBasedApp::Run() { try { // Initialize all services - // Temporarily disabled for testing - // lifecycleController_->InitializeAll(); + lifecycleController_->InitializeAll(); // Create the window auto windowService = registry_.GetService(); diff --git a/src/services/impl/sdl_window_service.cpp b/src/services/impl/sdl_window_service.cpp index 11343f0..b7f26aa 100644 --- a/src/services/impl/sdl_window_service.cpp +++ b/src/services/impl/sdl_window_service.cpp @@ -62,12 +62,17 @@ void SdlWindowService::Initialize() { throw std::runtime_error("SdlWindowService already initialized"); } - try { - ThrowSdlErrorIfFailed(SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO), "SDL_Init failed"); - } catch (const std::exception& e) { - ShowErrorDialog("SDL Initialization Failed", - std::string("Failed to initialize SDL subsystems.\n\nError: ") + e.what()); - throw; + // Check if SDL is already initialized + if (SDL_WasInit(0) == 0) { + try { + ThrowSdlErrorIfFailed(SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO), "SDL_Init failed"); + } catch (const std::exception& e) { + ShowErrorDialog("SDL Initialization Failed", + std::string("Failed to initialize SDL subsystems.\n\nError: ") + e.what()); + throw; + } + } else { + logging::Logger::GetInstance().Info("SDL already initialized, skipping SDL_Init"); } try {