From 41893927c1181cf987364eae31f462049bba1027 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Thu, 10 Oct 2002 09:00:31 +0000 Subject: [PATCH] From Gabor Dorka, Fixes to memory leaks. --- src/osgText/FTBitmapGlyph.cpp | 7 +++++-- src/osgText/FTOutlineGlyph.cpp | 5 +++++ src/osgText/FTPixmapGlyph.cpp | 7 +++++-- src/osgText/FTPolyGlyph.cpp | 8 +++++++- 4 files changed, 22 insertions(+), 5 deletions(-) diff --git a/src/osgText/FTBitmapGlyph.cpp b/src/osgText/FTBitmapGlyph.cpp index 63f9cd583..1e9dde778 100644 --- a/src/osgText/FTBitmapGlyph.cpp +++ b/src/osgText/FTBitmapGlyph.cpp @@ -24,8 +24,11 @@ FTBitmapGlyph::FTBitmapGlyph( FT_Glyph glyph) int srcHeight = source->rows; int srcPitch = source->pitch; - if (srcPitch*srcHeight==0) return; - + if (srcPitch*srcHeight==0) + { + FT_Done_Glyph( glyph ); + return; + } pos.x = bitmap->left; pos.y = srcHeight - bitmap->top; diff --git a/src/osgText/FTOutlineGlyph.cpp b/src/osgText/FTOutlineGlyph.cpp index 3039cd895..8dea1058b 100644 --- a/src/osgText/FTOutlineGlyph.cpp +++ b/src/osgText/FTOutlineGlyph.cpp @@ -15,6 +15,7 @@ FTOutlineGlyph::FTOutlineGlyph( FT_Glyph glyph) { if( ft_glyph_format_outline != glyph->format) { + FT_Done_Glyph( glyph); return; } @@ -27,6 +28,7 @@ FTOutlineGlyph::FTOutlineGlyph( FT_Glyph glyph) if (numContours==0) { + FT_Done_Glyph( glyph); return; } @@ -50,7 +52,10 @@ FTOutlineGlyph::FTOutlineGlyph( FT_Glyph glyph) vectoriser=0; if ( ( numContours < 1) || ( numPoints < 3)) + { + FT_Done_Glyph( glyph); return; + } glList = glGenLists(1); int d = 0; diff --git a/src/osgText/FTPixmapGlyph.cpp b/src/osgText/FTPixmapGlyph.cpp index 3cd46f143..cb9bfb428 100644 --- a/src/osgText/FTPixmapGlyph.cpp +++ b/src/osgText/FTPixmapGlyph.cpp @@ -27,8 +27,11 @@ FTPixmapGlyph::FTPixmapGlyph( FT_Glyph glyph) int srcHeight = source->rows; int srcPitch = source->pitch; - if (srcWidth*srcHeight==0) return; - + if (srcWidth*srcHeight==0) + { + FT_Done_Glyph( glyph ); + return; + } numGreys = source->num_grays; pos.x = bitmap->left; diff --git a/src/osgText/FTPolyGlyph.cpp b/src/osgText/FTPolyGlyph.cpp index 3ae3905be..83412f00b 100644 --- a/src/osgText/FTPolyGlyph.cpp +++ b/src/osgText/FTPolyGlyph.cpp @@ -64,7 +64,10 @@ FTPolyGlyph::FTPolyGlyph( FT_Glyph glyph) glList(0) { if( ft_glyph_format_outline != glyph->format) - { return;} + { + FT_Done_Glyph( glyph ); + return; + } advance = glyph->advance.x >> 16; @@ -96,7 +99,10 @@ FTPolyGlyph::FTPolyGlyph( FT_Glyph glyph) vectoriser=0; // delete it, using ref_ptr. if ( ( numContours < 1) || ( numPoints < 3)) + { + FT_Done_Glyph( glyph ); return; + } Tesselate();