Fix a crash in Text:set. Fixes issue #1639

This commit is contained in:
Alex Szpakowski
2020-10-16 21:19:50 -03:00
parent 510354e276
commit 2b0f8495bf
2 changed files with 1 additions and 5 deletions
-4
View File
@@ -33,7 +33,6 @@ love::Type Text::type("Text", &Drawable::type);
Text::Text(Font *font, const std::vector<Font::ColoredString> &text) Text::Text(Font *font, const std::vector<Font::ColoredString> &text)
: font(font) : font(font)
, vertexAttributes(Font::vertexFormat, 0) , vertexAttributes(Font::vertexFormat, 0)
, vertex_buffer(nullptr)
, vert_offset(0) , vert_offset(0)
, texture_cache_id((uint32) -1) , texture_cache_id((uint32) -1)
{ {
@@ -42,8 +41,6 @@ Text::Text(Font *font, const std::vector<Font::ColoredString> &text)
Text::~Text() Text::~Text()
{ {
if (vertex_buffer)
vertex_buffer->release();
} }
void Text::uploadVertices(const std::vector<Font::GlyphVertex> &vertices, size_t vertoffset) void Text::uploadVertices(const std::vector<Font::GlyphVertex> &vertices, size_t vertoffset)
@@ -68,7 +65,6 @@ void Text::uploadVertices(const std::vector<Font::GlyphVertex> &vertices, size_t
if (vertex_buffer != nullptr) if (vertex_buffer != nullptr)
vertex_buffer->copyTo(0, vertex_buffer->getSize(), new_buffer, 0); vertex_buffer->copyTo(0, vertex_buffer->getSize(), new_buffer, 0);
vertex_buffer->release();
vertex_buffer = new_buffer; vertex_buffer = new_buffer;
vertexBuffers.set(0, vertex_buffer, 0); vertexBuffers.set(0, vertex_buffer, 0);
+1 -1
View File
@@ -88,7 +88,7 @@ private:
VertexAttributes vertexAttributes; VertexAttributes vertexAttributes;
BufferBindings vertexBuffers; BufferBindings vertexBuffers;
Buffer *vertex_buffer; StrongRef<Buffer> vertex_buffer;
std::vector<Font::DrawCommand> draw_commands; std::vector<Font::DrawCommand> draw_commands;