feat: Re-enable service initialization in ServiceBasedApp and improve SDL initialization check in SdlWindowService

This commit is contained in:
2026-01-04 13:54:56 +00:00
parent 92967ac971
commit 5f76776f47
2 changed files with 12 additions and 8 deletions

View File

@@ -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<services::IWindowService>();

View File

@@ -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 {