Fixed more uninitialized variables and two potential memory leaks.

This commit is contained in:
Robert Osfield
2002-07-22 12:41:55 +00:00
parent bfefb55a9f
commit 3dd07ea354
9 changed files with 36 additions and 12 deletions

View File

@@ -3,10 +3,10 @@
#include "FTCharmap.h"
#include "FTGL.h"
FTFace::FTFace():
charMap(0),
ftFace(0),
ftGlyph(0),
numCharMaps(0),
numGlyphs(0),
err(0)

View File

@@ -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;

View File

@@ -28,6 +28,7 @@ FTGLTextureFont::FTGLTextureFont()
glyphWidth(0),
padding(1)
{
glContextTextureID.resize(osg::DisplaySettings::instance()->getMaxNumberOfGraphicsContexts(),0);
}

View File

@@ -1,12 +1,21 @@
#include "FTGlyph.h"
#include <iostream>
#include <string.h>
FTGlyph::FTGlyph()
: advance(0),
err(0)
{
pos.x = 0;
//cout << "**** FTGlyph() size = "<<sizeof(FTGlyph)<<endl;
memset(this,0,sizeof(FTGlyph));
advance=0;
err=0;
pos.x = 0;
pos.y = 0;
}

View File

@@ -46,7 +46,7 @@ FTOutlineGlyph::FTOutlineGlyph( FT_Glyph glyph)
advance = glyph->advance.x >> 16;
osgDelete vectoriser;
vectoriser=0;
if ( ( numContours < 1) || ( numPoints < 3))
return;

View File

@@ -1,6 +1,8 @@
#ifndef __FTOutlineGlyph__
#define __FTOutlineGlyph__
#include <osg/ref_ptr>
#include "FTGL.h"
#include <ft2build.h>
@@ -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<FTVectoriser> vectoriser;
/**
* The total number of points in the Freetype outline

View File

@@ -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;

View File

@@ -1,6 +1,8 @@
#ifndef __FTPolyGlyph__
#define __FTPolyGlyph__
#include <osg/ref_ptr>
#include "FTGL.h"
#include <ft2build.h>
@@ -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<FTVectoriser> vectoriser;
/**
* The total number of points in the Freetype outline

View File

@@ -3,6 +3,8 @@
#include "FTGL.h"
#include <osg/Referenced>
#include <vector>
#include <ft2build.h>
@@ -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:
/**