From 5dfcf90e6669e11489543d7f0228808df55854d5 Mon Sep 17 00:00:00 2001 From: Alex Szpakowski Date: Tue, 1 Oct 2019 19:02:16 -0300 Subject: [PATCH] Fix Text:set(" ") not properly clearing the internal buffer (resolves issue #1518). --- src/modules/graphics/Text.cpp | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/modules/graphics/Text.cpp b/src/modules/graphics/Text.cpp index 145c94abd..a38b4a901 100644 --- a/src/modules/graphics/Text.cpp +++ b/src/modules/graphics/Text.cpp @@ -111,21 +111,23 @@ void Text::addTextData(const TextData &t) else new_commands = font->generateVerticesFormatted(t.codepoints, constantcolor, t.wrap, t.align, vertices, &text_info); + size_t voffset = vert_offset; + + // Must be before the early exit below. + if (!t.append_vertices) + { + voffset = 0; + vert_offset = 0; + draw_commands.clear(); + text_data.clear(); + } + if (vertices.empty()) return; if (t.use_matrix) t.matrix.transformXY(&vertices[0], &vertices[0], (int) vertices.size()); - size_t voffset = vert_offset; - - if (!t.append_vertices) - { - voffset = 0; - draw_commands.clear(); - text_data.clear(); - } - uploadVertices(vertices, voffset); if (!new_commands.empty())