mirror of
https://github.com/love2d/love.git
synced 2026-08-12 08:30:56 +02:00
Fix love.event.quit causing crashes and other bad behaviour if a Canvas is active. Resolves issue #1395.
This commit is contained in:
@@ -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<Graphics>(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<Graphics>(Module::M_GRAPHICS);
|
||||
if (gfx != nullptr)
|
||||
gfx->cleanupCanvas(this);
|
||||
}
|
||||
|
||||
if (fbo != 0)
|
||||
gl.deleteFramebuffer(fbo);
|
||||
|
||||
@@ -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<graphics::Graphics>(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;
|
||||
|
||||
@@ -121,6 +121,8 @@ public:
|
||||
|
||||
private:
|
||||
|
||||
void close(bool allowExceptions);
|
||||
|
||||
struct ContextAttribs
|
||||
{
|
||||
int versionMajor;
|
||||
|
||||
Reference in New Issue
Block a user