diff --git a/src/modules/graphics/opengl/Canvas.cpp b/src/modules/graphics/opengl/Canvas.cpp index 06457498d..221a3e34d 100644 --- a/src/modules/graphics/opengl/Canvas.cpp +++ b/src/modules/graphics/opengl/Canvas.cpp @@ -271,11 +271,14 @@ bool Canvas::loadVolatile() void Canvas::unloadVolatile() { - // This is a bit ugly, but we need some way to destroy the cached FBO - // when this Canvas' texture is destroyed. - auto gfx = Module::getInstance(Module::M_GRAPHICS); - if (gfx != nullptr) - gfx->cleanupCanvas(this); + if (fbo != 0 || renderbuffer != 0 || texture != 0) + { + // This is a bit ugly, but we need some way to destroy the cached FBO + // when this Canvas' texture is destroyed. + auto gfx = Module::getInstance(Module::M_GRAPHICS); + if (gfx != nullptr) + gfx->cleanupCanvas(this); + } if (fbo != 0) gl.deleteFramebuffer(fbo); diff --git a/src/modules/window/sdl/Window.cpp b/src/modules/window/sdl/Window.cpp index 6672947ac..f175feef7 100644 --- a/src/modules/window/sdl/Window.cpp +++ b/src/modules/window/sdl/Window.cpp @@ -77,7 +77,7 @@ Window::Window() Window::~Window() { - close(); + close(false); graphics.set(nullptr); @@ -413,7 +413,7 @@ bool Window::setWindow(int width, int height, WindowSettings *settings) graphics.set(Module::getInstance(Module::M_GRAPHICS)); if (graphics.get() && graphics->isCanvasActive()) - throw love::Exception("setMode cannot be called while a Canvas is active in love.graphics."); + throw love::Exception("love.window.setMode cannot be called while a Canvas is active in love.graphics."); WindowSettings f; @@ -640,11 +640,16 @@ void Window::getWindow(int &width, int &height, WindowSettings &newsettings) } void Window::close() +{ + close(true); +} + +void Window::close(bool allowExceptions) { if (graphics.get()) { - if (graphics->isCanvasActive()) - throw love::Exception("close cannot be called while a Canvas is active in love.graphics."); + if (allowExceptions && graphics->isCanvasActive()) + throw love::Exception("love.window.close cannot be called while a Canvas is active in love.graphics."); graphics->unSetMode(); } @@ -674,7 +679,7 @@ bool Window::setFullscreen(bool fullscreen, Window::FullscreenType fstype) return false; if (graphics.get() && graphics->isCanvasActive()) - throw love::Exception("setFullscreen cannot be called while a Canvas is active in love.graphics."); + throw love::Exception("love.window.setFullscreen cannot be called while a Canvas is active in love.graphics."); WindowSettings newsettings = settings; newsettings.fullscreen = fullscreen; diff --git a/src/modules/window/sdl/Window.h b/src/modules/window/sdl/Window.h index ec643e22b..0ed8bc5de 100644 --- a/src/modules/window/sdl/Window.h +++ b/src/modules/window/sdl/Window.h @@ -121,6 +121,8 @@ public: private: + void close(bool allowExceptions); + struct ContextAttribs { int versionMajor;