Browse Source

Fix love.window.setMode crashing if a Canvas is active.

Alex Szpakowski 9 years ago
parent
commit
090c50795a

+ 2 - 1
src/modules/graphics/opengl/Canvas.cpp

@@ -521,7 +521,8 @@ void Canvas::stopGrab(bool switchingToOtherCanvas)
 	// Make sure the canvas texture is up to date if we're using MSAA.
 	// Make sure the canvas texture is up to date if we're using MSAA.
 	resolveMSAA(false);
 	resolveMSAA(false);
 
 
-	gl.matrices.projection.pop_back();
+	if (gl.matrices.projection.size() > 1)
+		gl.matrices.projection.pop_back();
 
 
 	if (!switchingToOtherCanvas)
 	if (!switchingToOtherCanvas)
 	{
 	{

+ 2 - 2
src/modules/graphics/opengl/Graphics.cpp

@@ -252,8 +252,6 @@ bool Graphics::setMode(int width, int height)
 
 
 	created = true;
 	created = true;
 
 
-	setViewportSize(width, height);
-
 	// Enable blending
 	// Enable blending
 	glEnable(GL_BLEND);
 	glEnable(GL_BLEND);
 
 
@@ -310,6 +308,8 @@ bool Graphics::setMode(int width, int height)
 	if (quadIndices == nullptr)
 	if (quadIndices == nullptr)
 		quadIndices = new QuadIndices(20);
 		quadIndices = new QuadIndices(20);
 
 
+	setViewportSize(width, height);
+
 	// Restore the graphics state.
 	// Restore the graphics state.
 	restoreState(states.back());
 	restoreState(states.back());