diff --git a/src/anbox/ubuntu/window.cpp b/src/anbox/ubuntu/window.cpp index d5ed5a6..4aca99f 100644 --- a/src/anbox/ubuntu/window.cpp +++ b/src/anbox/ubuntu/window.cpp @@ -342,8 +342,10 @@ Window::Window(const std::shared_ptr &input_manager, width, height, SDL_WINDOW_OPENGL | SDL_WINDOW_MAXIMIZED); - if (!window_) - BOOST_THROW_EXCEPTION(std::runtime_error("Failed to create new window")); + if (!window_) { + const auto message = utils::string_format("Failed to create window: %s", SDL_GetError()); + BOOST_THROW_EXCEPTION(std::runtime_error(message)); + } SDL_SysWMinfo info; diff --git a/src/anbox/ubuntu/window_creator.cpp b/src/anbox/ubuntu/window_creator.cpp index 29fed02..dae1675 100644 --- a/src/anbox/ubuntu/window_creator.cpp +++ b/src/anbox/ubuntu/window_creator.cpp @@ -68,21 +68,26 @@ void WindowCreator::process_events() { } } -EGLNativeWindowType WindowCreator::create_window(int x, int y, int width, int height) { - DEBUG("x %i y %i width %i height %i", x, y, width, height); - +EGLNativeWindowType WindowCreator::create_window(int x, int y, int width, int height) +try { if (windows_.size() == 1) { WARNING("Tried to create another window but we currently only allow one"); return 0; } auto window = std::make_shared(input_manager_, width, height); - windows_.insert({window->native_window(), window}); + if (not window) + BOOST_THROW_EXCEPTION(std::bad_alloc()); + windows_.insert({window->native_window(), window}); current_window_ = window; return window->native_window(); } +catch (std::exception &err) { + DEBUG("Failed to create window: %s", err.what()); + return 0; +} void WindowCreator::destroy_window(EGLNativeWindowType win) { auto iter = windows_.find(win);