Explorar o código

Merge pull request #1667 from seanpaultaylor/next

Fixes #1666 - Font memory leak
Sean Taylor %!s(int64=11) %!d(string=hai) anos
pai
achega
f812e61da5
Modificáronse 2 ficheiros con 4 adicións e 1 borrados
  1. 3 1
      gameplay/src/Font.cpp
  2. 1 0
      gameplay/src/Font.h

+ 3 - 1
gameplay/src/Font.cpp

@@ -17,7 +17,7 @@ static std::vector<Font*> __fontCache;
 static Effect* __fontEffect = NULL;
 
 Font::Font() :
-    _format(BITMAP), _style(PLAIN), _size(0), _spacing(0.0f), _glyphs(NULL), _glyphCount(0), _batch(NULL), _cutoffParam(NULL)
+    _format(BITMAP), _style(PLAIN), _size(0), _spacing(0.0f), _glyphs(NULL), _glyphCount(0), _texture(NULL), _batch(NULL), _cutoffParam(NULL)
 {
 }
 
@@ -32,6 +32,7 @@ Font::~Font()
 
     SAFE_DELETE(_batch);
     SAFE_DELETE_ARRAY(_glyphs);
+    SAFE_RELEASE(_texture);
 
     // Free child fonts
     for (size_t i = 0, count = _sizes.size(); i < count; ++i)
@@ -146,6 +147,7 @@ Font* Font::create(const char* family, Style style, unsigned int size, Glyph* gl
     font->_family = family;
     font->_style = style;
     font->_size = size;
+    font->_texture = texture;
     font->_batch = batch;
 
     // Copy the glyphs array.

+ 1 - 0
gameplay/src/Font.h

@@ -343,6 +343,7 @@ private:
     float _spacing;
     Glyph* _glyphs;
     unsigned int _glyphCount;
+    Texture* _texture;
     SpriteBatch* _batch;
     Rectangle _viewport;
     MaterialParameter* _cutoffParam;