From 3dd07ea3545842dfd58ad65522c1558cef6d4185 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Mon, 22 Jul 2002 12:41:55 +0000 Subject: [PATCH] Fixed more uninitialized variables and two potential memory leaks. --- src/osgText/FTFace.cpp | 2 +- src/osgText/FTFont.cpp | 3 +++ src/osgText/FTGLTextureFont.cpp | 1 + src/osgText/FTGlyph.cpp | 11 ++++++++++- src/osgText/FTOutlineGlyph.cpp | 2 +- src/osgText/FTOutlineGlyph.h | 14 ++++++++++---- src/osgText/FTPolyGlyph.cpp | 2 +- src/osgText/FTPolyGlyph.h | 7 ++++--- src/osgText/FTVectoriser.h | 6 +++++- 9 files changed, 36 insertions(+), 12 deletions(-) diff --git a/src/osgText/FTFace.cpp b/src/osgText/FTFace.cpp index 8a214cdca..da0dee24e 100644 --- a/src/osgText/FTFace.cpp +++ b/src/osgText/FTFace.cpp @@ -3,10 +3,10 @@ #include "FTCharmap.h" #include "FTGL.h" - FTFace::FTFace(): charMap(0), ftFace(0), + ftGlyph(0), numCharMaps(0), numGlyphs(0), err(0) diff --git a/src/osgText/FTFont.cpp b/src/osgText/FTFont.cpp index 9ba77b458..169d74fd2 100644 --- a/src/osgText/FTFont.cpp +++ b/src/osgText/FTFont.cpp @@ -7,10 +7,13 @@ // mrn@changes FTFont::FTFont(): + face(), numFaces(0), numGlyphs(0), err(0) { + + _contextGlyphList.resize(osg::DisplaySettings::instance()->getMaxNumberOfGraphicsContexts(),NULL); pen.x = 0; diff --git a/src/osgText/FTGLTextureFont.cpp b/src/osgText/FTGLTextureFont.cpp index e037fc2c8..21087cb21 100644 --- a/src/osgText/FTGLTextureFont.cpp +++ b/src/osgText/FTGLTextureFont.cpp @@ -28,6 +28,7 @@ FTGLTextureFont::FTGLTextureFont() glyphWidth(0), padding(1) { + glContextTextureID.resize(osg::DisplaySettings::instance()->getMaxNumberOfGraphicsContexts(),0); } diff --git a/src/osgText/FTGlyph.cpp b/src/osgText/FTGlyph.cpp index de8d87833..73f9f1ccc 100644 --- a/src/osgText/FTGlyph.cpp +++ b/src/osgText/FTGlyph.cpp @@ -1,12 +1,21 @@ #include "FTGlyph.h" +#include +#include FTGlyph::FTGlyph() : advance(0), err(0) { - pos.x = 0; + //cout << "**** FTGlyph() size = "<advance.x >> 16; - osgDelete vectoriser; + vectoriser=0; if ( ( numContours < 1) || ( numPoints < 3)) return; diff --git a/src/osgText/FTOutlineGlyph.h b/src/osgText/FTOutlineGlyph.h index 5c6e34061..af3e430a6 100644 --- a/src/osgText/FTOutlineGlyph.h +++ b/src/osgText/FTOutlineGlyph.h @@ -1,6 +1,8 @@ #ifndef __FTOutlineGlyph__ #define __FTOutlineGlyph__ +#include + #include "FTGL.h" #include @@ -8,9 +10,7 @@ #include FT_GLYPH_H #include "FTGlyph.h" - -class FTVectoriser; - +#include "FTVectoriser.h" /** * FTOutlineGlyph is a specialisation of FTGlyph for creating outlines. @@ -28,6 +28,7 @@ class FTGL_EXPORT FTOutlineGlyph : public FTGlyph * @param glyph The Freetype glyph to be processed */ FTOutlineGlyph( FT_Glyph glyph); + /** * Destructor @@ -43,11 +44,16 @@ class FTGL_EXPORT FTOutlineGlyph : public FTGlyph virtual float Render( const FT_Vector& pen); private: + + FTOutlineGlyph() {} + + FTOutlineGlyph(const FTOutlineGlyph&):FTGlyph() {} + /** * An object that helps convert freetype outlines into point * data */ - FTVectoriser* vectoriser; + osg::ref_ptr vectoriser; /** * The total number of points in the Freetype outline diff --git a/src/osgText/FTPolyGlyph.cpp b/src/osgText/FTPolyGlyph.cpp index 2df36ddc7..8e4fd4281 100644 --- a/src/osgText/FTPolyGlyph.cpp +++ b/src/osgText/FTPolyGlyph.cpp @@ -92,7 +92,7 @@ FTPolyGlyph::FTPolyGlyph( FT_Glyph glyph) contourFlag = vectoriser->ContourFlag(); advance = glyph->advance.x >> 16; - osgDelete vectoriser; + vectoriser=0; // delete it, using ref_ptr. if ( ( numContours < 1) || ( numPoints < 3)) return; diff --git a/src/osgText/FTPolyGlyph.h b/src/osgText/FTPolyGlyph.h index 0ff3e24a7..56bff0d91 100644 --- a/src/osgText/FTPolyGlyph.h +++ b/src/osgText/FTPolyGlyph.h @@ -1,6 +1,8 @@ #ifndef __FTPolyGlyph__ #define __FTPolyGlyph__ +#include + #include "FTGL.h" #include @@ -8,8 +10,7 @@ #include FT_GLYPH_H #include "FTGlyph.h" - -class FTVectoriser; +#include "FTVectoriser.h" /** * FTPolyGlyph is a specialisation of FTGlyph for creating tessellated @@ -54,7 +55,7 @@ class FTGL_EXPORT FTPolyGlyph : public FTGlyph * An object that helps convert freetype outlines into point * data */ - FTVectoriser* vectoriser; + osg::ref_ptr vectoriser; /** * The total number of points in the Freetype outline diff --git a/src/osgText/FTVectoriser.h b/src/osgText/FTVectoriser.h index 78aeab2ce..42c3bf911 100644 --- a/src/osgText/FTVectoriser.h +++ b/src/osgText/FTVectoriser.h @@ -3,6 +3,8 @@ #include "FTGL.h" +#include + #include #include @@ -11,6 +13,8 @@ #include "FTGlyph.h" + + using namespace std; /** @@ -140,7 +144,7 @@ class FTGL_EXPORT FTContour * @see ftPoint * */ -class FTGL_EXPORT FTVectoriser +class FTGL_EXPORT FTVectoriser : public osg::Referenced { public: /**