Browse Source

Fix love.graphics.draw(TextBatch) accessing an invalid pointer.

Fixes #1922.
Fixes #1914.
Sasha Szpakowski 2 years ago
parent
commit
90b22f7d42
1 changed files with 4 additions and 4 deletions
  1. 4 4
      src/modules/graphics/TextBatch.cpp

+ 4 - 4
src/modules/graphics/TextBatch.cpp

@@ -255,6 +255,10 @@ void TextBatch::draw(Graphics *gfx, const Matrix4 &m)
 
 
 	gfx->flushBatchedDraws();
 	gfx->flushBatchedDraws();
 
 
+	// Re-generate the text if the Font's texture cache was invalidated.
+	if (font->getTextureCacheID() != textureCacheID)
+		regenerateVertices();
+
 	if (Shader::isDefaultActive())
 	if (Shader::isDefaultActive())
 		Shader::attachDefault(Shader::STANDARD_DEFAULT);
 		Shader::attachDefault(Shader::STANDARD_DEFAULT);
 
 
@@ -265,10 +269,6 @@ void TextBatch::draw(Graphics *gfx, const Matrix4 &m)
 	if (Shader::current)
 	if (Shader::current)
 		Shader::current->validateDrawState(PRIMITIVE_TRIANGLES, firsttex);
 		Shader::current->validateDrawState(PRIMITIVE_TRIANGLES, firsttex);
 
 
-	// Re-generate the text if the Font's texture cache was invalidated.
-	if (font->getTextureCacheID() != textureCacheID)
-		regenerateVertices();
-
 	int totalverts = 0;
 	int totalverts = 0;
 	for (const Font::DrawCommand &cmd : drawCommands)
 	for (const Font::DrawCommand &cmd : drawCommands)
 		totalverts = std::max(cmd.startvertex + cmd.vertexcount, totalverts);
 		totalverts = std::max(cmd.startvertex + cmd.vertexcount, totalverts);