From bfefb55a9f31b0efbe42d21632349139f420ca27 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Sun, 21 Jul 2002 20:34:38 +0000 Subject: [PATCH] Fixed various uninitiliazed variables. --- src/osgText/FTBitmapGlyph.cpp | 2 ++ src/osgText/FTFace.cpp | 9 ++++++--- src/osgText/FTFont.cpp | 5 +++-- src/osgText/FTGLTextureFont.cpp | 3 ++- src/osgText/FTOutlineGlyph.cpp | 13 ++++++++++++- src/osgText/FTPixmapGlyph.cpp | 2 ++ src/osgText/FTPolyGlyph.cpp | 8 ++++++++ src/osgText/FTSize.cpp | 2 +- src/osgText/FTTextureGlyph.cpp | 1 + src/osgText/FTVectoriser.cpp | 14 +++++++++++++- src/osgText/IO_Font.cpp | 10 +++++----- 11 files changed, 55 insertions(+), 14 deletions(-) diff --git a/src/osgText/FTBitmapGlyph.cpp b/src/osgText/FTBitmapGlyph.cpp index f8ff94b00..0f0b0b682 100644 --- a/src/osgText/FTBitmapGlyph.cpp +++ b/src/osgText/FTBitmapGlyph.cpp @@ -22,6 +22,8 @@ FTBitmapGlyph::FTBitmapGlyph( FT_Glyph glyph) int srcHeight = source->rows; int srcPitch = source->pitch; + if (srcPitch*srcHeight==0) return; + advance = glyph->advance.x >> 16; pos.x = bitmap->left; diff --git a/src/osgText/FTFace.cpp b/src/osgText/FTFace.cpp index 5a258707f..8a214cdca 100644 --- a/src/osgText/FTFace.cpp +++ b/src/osgText/FTFace.cpp @@ -4,13 +4,16 @@ #include "FTGL.h" -FTFace::FTFace() -: charMap(0), +FTFace::FTFace(): + charMap(0), ftFace(0), numCharMaps(0), numGlyphs(0), err(0) -{} +{ + kernAdvance.x = 0; + kernAdvance.y = 0; +} FTFace::~FTFace() diff --git a/src/osgText/FTFont.cpp b/src/osgText/FTFont.cpp index 816bfbb52..9ba77b458 100644 --- a/src/osgText/FTFont.cpp +++ b/src/osgText/FTFont.cpp @@ -6,8 +6,9 @@ #include // mrn@changes -FTFont::FTFont() -: numFaces(0), +FTFont::FTFont(): + numFaces(0), + numGlyphs(0), err(0) { _contextGlyphList.resize(osg::DisplaySettings::instance()->getMaxNumberOfGraphicsContexts(),NULL); diff --git a/src/osgText/FTGLTextureFont.cpp b/src/osgText/FTGLTextureFont.cpp index 0a43d6f91..e037fc2c8 100644 --- a/src/osgText/FTGLTextureFont.cpp +++ b/src/osgText/FTGLTextureFont.cpp @@ -69,7 +69,8 @@ bool FTGLTextureFont::MakeGlyphList(unsigned int renderContext) return true; else { - glTextureID=new unsigned long[16]; + glTextureID= osgNew unsigned long[16]; + memset(glTextureID,0,sizeof(unsigned long)*16); glContextTextureID[renderContext]=glTextureID; } diff --git a/src/osgText/FTOutlineGlyph.cpp b/src/osgText/FTOutlineGlyph.cpp index 6d29a5433..70343507e 100644 --- a/src/osgText/FTOutlineGlyph.cpp +++ b/src/osgText/FTOutlineGlyph.cpp @@ -22,8 +22,14 @@ FTOutlineGlyph::FTOutlineGlyph( FT_Glyph glyph) vectoriser->Process(); numContours = vectoriser->contours(); - contourLength = osgNew int[ numContours]; + if (numContours==0) + { + return; + } + + contourLength = osgNew int[ numContours]; + memset(contourLength,0,sizeof(int)*numContours); for( int cn = 0; cn < numContours; ++cn) { contourLength[cn] = vectoriser->contourSize( cn); @@ -31,6 +37,11 @@ FTOutlineGlyph::FTOutlineGlyph( FT_Glyph glyph) numPoints = vectoriser->points(); data = osgNew double[ numPoints * 3]; + for( int cp = 0; cp < numPoints * 3; ++cp) + { + data[cp]=0.0; + } + vectoriser->MakeOutline( data); advance = glyph->advance.x >> 16; diff --git a/src/osgText/FTPixmapGlyph.cpp b/src/osgText/FTPixmapGlyph.cpp index c41866327..3a6c448d7 100644 --- a/src/osgText/FTPixmapGlyph.cpp +++ b/src/osgText/FTPixmapGlyph.cpp @@ -26,6 +26,8 @@ FTPixmapGlyph::FTPixmapGlyph( FT_Glyph glyph) int srcHeight = source->rows; int srcPitch = source->pitch; + if (srcWidth*srcHeight==0) return; + numGreys = source->num_grays; advance = glyph->advance.x >> 16; diff --git a/src/osgText/FTPolyGlyph.cpp b/src/osgText/FTPolyGlyph.cpp index a78f10a95..2df36ddc7 100644 --- a/src/osgText/FTPolyGlyph.cpp +++ b/src/osgText/FTPolyGlyph.cpp @@ -58,6 +58,7 @@ FTPolyGlyph::FTPolyGlyph( FT_Glyph glyph) vectoriser(0), numPoints(0), numContours(0), + contourFlag(0), contourLength(0), data(0), glList(0) @@ -69,7 +70,11 @@ FTPolyGlyph::FTPolyGlyph( FT_Glyph glyph) vectoriser->Process(); numContours = vectoriser->contours(); + + if (numContours==0) return; + contourLength = osgNew int[ numContours]; + memset(contourLength,0,sizeof(int)*numContours); for( int c = 0; c < numContours; ++c) { @@ -78,6 +83,9 @@ FTPolyGlyph::FTPolyGlyph( FT_Glyph glyph) numPoints = vectoriser->points(); data = osgNew double[ numPoints * 3]; + // initalize memory. + for( int pc=0;pcMakeOutline( data); diff --git a/src/osgText/FTSize.cpp b/src/osgText/FTSize.cpp index fc2bc605f..5a45d0933 100644 --- a/src/osgText/FTSize.cpp +++ b/src/osgText/FTSize.cpp @@ -4,11 +4,11 @@ FTSize::FTSize() : ftFace(0), + ftSize(0), size(0), err(0) {} - FTSize::~FTSize() {} diff --git a/src/osgText/FTTextureGlyph.cpp b/src/osgText/FTTextureGlyph.cpp index 6c3f04141..0569c5494 100644 --- a/src/osgText/FTTextureGlyph.cpp +++ b/src/osgText/FTTextureGlyph.cpp @@ -4,6 +4,7 @@ FTTextureGlyph::FTTextureGlyph( FT_Glyph glyph, int id, unsigned char* data, GLsizei stride, GLsizei height, float u, float v) : FTGlyph(), + activeTextureID(0), destWidth(0), destHeight(0), numGreys(0), diff --git a/src/osgText/FTVectoriser.cpp b/src/osgText/FTVectoriser.cpp index 762e80cc3..2fe300608 100644 --- a/src/osgText/FTVectoriser.cpp +++ b/src/osgText/FTVectoriser.cpp @@ -36,9 +36,21 @@ FTVectoriser::FTVectoriser( FT_Glyph glyph) ftOutline = outline->outline; contourList.reserve( ftOutline.n_contours); + + + for(int i=0;i<4;++i) + { + for(int j=0;j<4;++j) + { + bValues[i][j][0]=0.0f; + bValues[i][j][1]=0.0f; + } + ctrlPtArray[i][0]=0.0f; + ctrlPtArray[i][1]=0.0f; + } + } - FTVectoriser::~FTVectoriser() { for( int c = 0; c < contours(); ++c) diff --git a/src/osgText/IO_Font.cpp b/src/osgText/IO_Font.cpp index d46e59631..ceed0db35 100644 --- a/src/osgText/IO_Font.cpp +++ b/src/osgText/IO_Font.cpp @@ -60,7 +60,7 @@ bool BitmapFont_readLocalData(osg::Object &obj, osgDB::Input &fr) if (fr[0].matchWord("parameters")) { int psize; if (fr[1].getInt(psize) && fr[2].isInt() && fr[3].isString()) { - osgText::BitmapFont *temp = new osgText::BitmapFont(std::string(fr[3].getStr()), psize); + osgText::BitmapFont *temp = osgNew osgText::BitmapFont(std::string(fr[3].getStr()), psize); temp->copyAndInvalidate(myobj); fr += 4; itAdvanced = true; @@ -94,7 +94,7 @@ bool PixmapFont_readLocalData(osg::Object &obj, osgDB::Input &fr) if (fr[0].matchWord("parameters")) { int psize; if (fr[1].getInt(psize) && fr[2].isInt() && fr[3].isString()) { - osgText::PixmapFont *temp = new osgText::PixmapFont(std::string(fr[3].getStr()), psize); + osgText::PixmapFont *temp = osgNew osgText::PixmapFont(std::string(fr[3].getStr()), psize); temp->copyAndInvalidate(myobj); fr += 4; itAdvanced = true; @@ -127,7 +127,7 @@ bool TextureFont_readLocalData(osg::Object &obj, osgDB::Input &fr) if (fr[0].matchWord("parameters")) { int psize, txsize; if (fr[1].getInt(psize) && fr[2].getInt(txsize) && fr[3].isString()) { - osgText::TextureFont *temp = new osgText::TextureFont(std::string(fr[3].getStr()), psize, txsize); + osgText::TextureFont *temp = osgNew osgText::TextureFont(std::string(fr[3].getStr()), psize, txsize); temp->copyAndInvalidate(myobj); fr += 4; itAdvanced = true; @@ -161,7 +161,7 @@ bool OutlineFont_readLocalData(osg::Object &obj, osgDB::Input &fr) if (fr[0].matchWord("parameters")) { int psize; if (fr[1].getInt(psize) && fr[2].isInt() && fr[3].isString()) { - osgText::OutlineFont *temp = new osgText::OutlineFont(std::string(fr[3].getStr()), psize, 1); + osgText::OutlineFont *temp = osgNew osgText::OutlineFont(std::string(fr[3].getStr()), psize, 1); temp->copyAndInvalidate(myobj); fr += 4; itAdvanced = true; @@ -194,7 +194,7 @@ bool PolygonFont_readLocalData(osg::Object &obj, osgDB::Input &fr) if (fr[0].matchWord("parameters")) { int psize; if (fr[1].getInt(psize) && fr[2].isInt() && fr[3].isString()) { - osgText::PolygonFont *temp = new osgText::PolygonFont(std::string(fr[3].getStr()), psize, 1); + osgText::PolygonFont *temp = osgNew osgText::PolygonFont(std::string(fr[3].getStr()), psize, 1); temp->copyAndInvalidate(myobj); fr += 4; itAdvanced = true;