From 2b273c0081b3b7db4f59b566e8db9032b5f0f0e8 Mon Sep 17 00:00:00 2001 From: Bart van Strien Date: Sat, 18 Sep 2010 10:07:52 +0200 Subject: [PATCH] Hopefully fixed more memory leakage in fonts --- src/modules/font/GlyphData.cpp | 2 +- src/modules/graphics/opengl/Font.cpp | 12 ++++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/modules/font/GlyphData.cpp b/src/modules/font/GlyphData.cpp index cd5e9dc53..3fb243a81 100644 --- a/src/modules/font/GlyphData.cpp +++ b/src/modules/font/GlyphData.cpp @@ -45,7 +45,7 @@ namespace font GlyphData::~GlyphData() { - delete data; + delete[] data; } void * GlyphData::getData() const diff --git a/src/modules/graphics/opengl/Font.cpp b/src/modules/graphics/opengl/Font.cpp index 0072d91da..c16f470a9 100644 --- a/src/modules/graphics/opengl/Font.cpp +++ b/src/modules/graphics/opengl/Font.cpp @@ -34,7 +34,7 @@ namespace opengl : height(data->getHeight()), lineHeight(1.25), mSpacing(1) { glyphs = new Glyph*[MAX_CHARS]; - + for(unsigned int i = 0; i < MAX_CHARS; i++) { glyphs[i] = new Glyph(data->getGlyphData(i)); @@ -48,6 +48,10 @@ namespace opengl Font::~Font() { + for(unsigned int i = 0; i < MAX_CHARS; i++) + { + delete glyphs[i]; + } delete[] glyphs; } @@ -166,20 +170,20 @@ namespace opengl { return mSpacing; } - + bool Font::loadVolatile() { // reload all glyphs for(unsigned int i = 0; i < MAX_CHARS; i++) { - glyphs[i]->load(); + glyphs[i]->load(); glNewList(list + i, GL_COMPILE); glyphs[i]->draw(0, 0, 0, 1, 1, 0, 0); glEndList(); } return true; } - + void Font::unloadVolatile() { // delete the glyphs