From 6b3295f8a803ccdbdb8f4836e2e8b62f8df4e1ac Mon Sep 17 00:00:00 2001 From: Simon Fels Date: Sun, 20 Aug 2017 14:03:24 +0200 Subject: [PATCH] Only attempt to create a renderer when we don't have one already --- src/anbox/ui/splash_screen.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/anbox/ui/splash_screen.cpp b/src/anbox/ui/splash_screen.cpp index b52c817..d5b9b48 100644 --- a/src/anbox/ui/splash_screen.cpp +++ b/src/anbox/ui/splash_screen.cpp @@ -18,6 +18,7 @@ #include "anbox/ui/splash_screen.h" #include "anbox/config.h" #include "anbox/utils.h" +#include "anbox/logger.h" #include @@ -44,9 +45,15 @@ SplashScreen::SplashScreen() { SDL_FillRect(surface, nullptr, SDL_MapRGB(surface->format, 0xee, 0xee, 0xee)); SDL_UpdateWindowSurface(window_); - auto renderer = SDL_CreateRenderer(window_, -1, SDL_RENDERER_ACCELERATED); - if (!renderer) - BOOST_THROW_EXCEPTION(std::runtime_error("Could not create renderer")); + auto renderer = SDL_GetRenderer(window_); + if (!renderer) { + DEBUG("Window has no associated renderer yet, creating one ..."); + renderer = SDL_CreateRenderer(window_, -1, SDL_RENDERER_ACCELERATED); + if (!renderer) { + const auto msg = utils::string_format("Could not create renderer: %s", SDL_GetError()); + BOOST_THROW_EXCEPTION(std::runtime_error(msg)); + } + } const auto icon_path = utils::string_format("%s/ui/loading-screen.png", SystemConfiguration::instance().resource_dir()); auto img = IMG_LoadTexture(renderer, icon_path.c_str());