From 90b22f7d42f953dbf4a2bc720b4a6e7d4b8c7b5a Mon Sep 17 00:00:00 2001 From: Sasha Szpakowski Date: Sat, 22 Apr 2023 21:59:15 -0300 Subject: [PATCH] Fix love.graphics.draw(TextBatch) accessing an invalid pointer. Fixes #1922. Fixes #1914. --- src/modules/graphics/TextBatch.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/modules/graphics/TextBatch.cpp b/src/modules/graphics/TextBatch.cpp index 797e68bb1..2a5deab46 100644 --- a/src/modules/graphics/TextBatch.cpp +++ b/src/modules/graphics/TextBatch.cpp @@ -255,6 +255,10 @@ void TextBatch::draw(Graphics *gfx, const Matrix4 &m) gfx->flushBatchedDraws(); + // Re-generate the text if the Font's texture cache was invalidated. + if (font->getTextureCacheID() != textureCacheID) + regenerateVertices(); + if (Shader::isDefaultActive()) Shader::attachDefault(Shader::STANDARD_DEFAULT); @@ -265,10 +269,6 @@ void TextBatch::draw(Graphics *gfx, const Matrix4 &m) if (Shader::current) 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; for (const Font::DrawCommand &cmd : drawCommands) totalverts = std::max(cmd.startvertex + cmd.vertexcount, totalverts);