Various fixes to constructors to ensure that all variables are initialized.

This commit is contained in:
Robert Osfield 2002-07-20 23:54:55 +00:00
parent 0ff08a2978
commit 48b3be40e9
16 changed files with 74 additions and 41 deletions

View File

@ -22,7 +22,7 @@ class SG_EXPORT CollectOccludersVisitor : public osg::NodeVisitor, public osg::C
CollectOccludersVisitor();
virtual ~CollectOccludersVisitor();
virtual CollectOccludersVisitor* cloneType() const { return new CollectOccludersVisitor(); }
virtual CollectOccludersVisitor* cloneType() const { return osgNew CollectOccludersVisitor(); }
virtual void reset();

View File

@ -40,6 +40,7 @@ typedef struct tag_au
unsigned int allocationNumber;
struct tag_au *next;
struct tag_au *prev;
bool printedOutUnintializedInfo;
} sAllocUnit;
typedef struct

View File

@ -209,7 +209,7 @@ class RegisterDotOsgWrapperProxy
{
if (Registry::instance())
{
_wrapper = new DotOsgWrapper(proto,name,associates,readFunc,writeFunc,readWriteMode);
_wrapper = osgNew DotOsgWrapper(proto,name,associates,readFunc,writeFunc,readWriteMode);
Registry::instance()->addDotOsgWrapper(_wrapper.get());
}
}
@ -235,7 +235,7 @@ class RegisterReaderWriterProxy
{
if (Registry::instance())
{
_rw = new T;
_rw = osgNew T;
Registry::instance()->addReaderWriter(_rw.get());
}
}

View File

@ -144,14 +144,21 @@ class OSGGLUT_EXPORT Viewer : public Window, public osgGA::GUIActionAdapter
int flat_shade;
float frRate; // gwm Jul 2001 added convolved ('averaged') frame rate
int _printStats; // gwm Jul 2001 change from bool
struct { // gwm Jul 2001, added for display of statistics
struct StatsRecord
{ // gwm Jul 2001, added for display of statistics
StatsRecord():
timeApp(0), timeCull(0), timeDraw(0), timeFrame(0),
frameend(0) {}
float timeApp, timeCull, timeDraw, timeFrame;
osg::Timer_t frameend;
} times[3]; // store up to 3 frames worth of times
};
StatsRecord times[3]; // store up to 3 frames worth of times
bool _useDisplayLists;
osg::Timer _timer;
osg::Timer_t _tickRatePerSecond;
osg::Timer_t _initialTick;
osg::Timer_t _lastFrameTick;
osg::Timer_t _frameTick;

View File

@ -44,7 +44,7 @@ class OSGUTIL_EXPORT CullVisitor : public osg::NodeVisitor, public osg::CullStac
CullVisitor();
virtual ~CullVisitor();
virtual CullVisitor* cloneType() const { return new CullVisitor(); }
virtual CullVisitor* cloneType() const { return osgNew CullVisitor(); }
virtual void reset();
@ -318,7 +318,7 @@ inline RenderLeaf* CullVisitor::createOrReuseRenderLeaf(osg::Drawable* drawable,
}
// otherwise need to create new renderleaf.
RenderLeaf* renderleaf = new RenderLeaf(drawable,projection,matrix,depth);
RenderLeaf* renderleaf = osgNew RenderLeaf(drawable,projection,matrix,depth);
_reuseRenderLeafList.push_back(renderleaf);
++_currentReuseRenderLeafIndex;
return renderleaf;

View File

@ -16,8 +16,8 @@ class OSGUTIL_EXPORT DepthSortedBin : public RenderBin
DepthSortedBin();
virtual osg::Object* cloneType() const { return new DepthSortedBin(); }
virtual osg::Object* clone(const osg::CopyOp&) const { return new DepthSortedBin(); } // note only implements a clone of type.
virtual osg::Object* cloneType() const { return osgNew DepthSortedBin(); }
virtual osg::Object* clone(const osg::CopyOp&) const { return osgNew DepthSortedBin(); } // note only implements a clone of type.
virtual bool isSameKindAs(const osg::Object* obj) const { return dynamic_cast<const DepthSortedBin*>(obj)!=0L; }
virtual const char* libraryName() const { return "osgUtil"; }
virtual const char* className() const { return "DepthSortedBin"; }

View File

@ -37,8 +37,8 @@ class OSGUTIL_EXPORT RenderBin : public osg::Object
RenderBin();
virtual osg::Object* cloneType() const { return new RenderBin(); }
virtual osg::Object* clone(const osg::CopyOp&) const { return new RenderBin(); } // note only implements a clone of type.
virtual osg::Object* cloneType() const { return osgNew RenderBin(); }
virtual osg::Object* clone(const osg::CopyOp&) const { return osgNew RenderBin(); } // note only implements a clone of type.
virtual bool isSameKindAs(const osg::Object* obj) const { return dynamic_cast<const RenderBin*>(obj)!=0L; }
virtual const char* libraryName() const { return "osgUtil"; }
virtual const char* className() const { return "RenderBin"; }
@ -93,7 +93,7 @@ class RegisterRenderBinProxy
public:
RegisterRenderBinProxy()
{
_rb = new T;
_rb = osgNew T;
RenderBin::addRenderBinPrototype(_rb.get());
}

View File

@ -51,21 +51,24 @@ class OSGUTIL_EXPORT RenderGraph : public osg::Referenced
_parent(NULL),
_stateset(NULL),
_depth(0),
_averageDistance(0)
_averageDistance(0),
_userData(NULL)
{
}
RenderGraph(RenderGraph* parent,const osg::StateSet* stateset):
_parent(parent),
_stateset(stateset)
_stateset(stateset),
_depth(0),
_averageDistance(0),
_userData(NULL)
{
if (_parent) _depth = _parent->_depth + 1;
else _depth = 0;
}
~RenderGraph() {}
RenderGraph* cloneType() const { return new RenderGraph; }
RenderGraph* cloneType() const { return osgNew RenderGraph; }
void setUserData(osg::Referenced* obj) { _userData = obj; }
osg::Referenced* getUserData() { return _userData.get(); }
@ -125,7 +128,7 @@ class OSGUTIL_EXPORT RenderGraph : public osg::Referenced
// create a state group and insert it into the children list
// then return the state group.
RenderGraph* sg = new RenderGraph(this,stateset);
RenderGraph* sg = osgNew RenderGraph(this,stateset);
_children[stateset] = sg;
return sg;
}

View File

@ -28,8 +28,8 @@ class OSGUTIL_EXPORT RenderStage : public RenderBin
RenderStage();
virtual osg::Object* cloneType() const { return new RenderStage(); }
virtual osg::Object* clone(const osg::CopyOp&) const { return new RenderStage(); } // note only implements a clone of type.
virtual osg::Object* cloneType() const { return osgNew RenderStage(); }
virtual osg::Object* clone(const osg::CopyOp&) const { return osgNew RenderStage(); } // note only implements a clone of type.
virtual bool isSameKindAs(const osg::Object* obj) const { return dynamic_cast<const RenderStage*>(obj)!=0L; }
virtual const char* className() const { return "RenderStage"; }
@ -96,7 +96,7 @@ class OSGUTIL_EXPORT RenderStage : public RenderBin
RenderStageLighting* getRenderStageLighting() const
{
if (!_renderStageLighting.valid()) _renderStageLighting = new RenderStageLighting;
if (!_renderStageLighting.valid()) _renderStageLighting = osgNew RenderStageLighting;
return _renderStageLighting.get();
}

View File

@ -23,8 +23,8 @@ class OSGUTIL_EXPORT RenderStageLighting : public osg::Object
RenderStageLighting();
virtual osg::Object* cloneType() const { return new RenderStageLighting(); }
virtual osg::Object* clone(const osg::CopyOp&) const { return new RenderStageLighting(); } // note only implements a clone of type.
virtual osg::Object* cloneType() const { return osgNew RenderStageLighting(); }
virtual osg::Object* clone(const osg::CopyOp&) const { return osgNew RenderStageLighting(); } // note only implements a clone of type.
virtual bool isSameKindAs(const osg::Object* obj) const { return dynamic_cast<const RenderStageLighting*>(obj)!=0L; }
virtual const char* libraryName() const { return "osgUtil"; }
virtual const char* className() const { return "RenderStageLighting"; }

View File

@ -23,8 +23,8 @@ class OSGUTIL_EXPORT RenderToTextureStage : public RenderStage
RenderToTextureStage();
virtual osg::Object* cloneType() const { return new RenderToTextureStage(); }
virtual osg::Object* clone(const osg::CopyOp&) const { return new RenderToTextureStage(); } // note only implements a clone of type.
virtual osg::Object* cloneType() const { return osgNew RenderToTextureStage(); }
virtual osg::Object* clone(const osg::CopyOp&) const { return osgNew RenderToTextureStage(); } // note only implements a clone of type.
virtual bool isSameKindAs(const osg::Object* obj) const { return dynamic_cast<const RenderToTextureStage*>(obj)!=0L; }
virtual const char* libraryName() const { return "osgUtil"; }
virtual const char* className() const { return "RenderToTextureStage"; }

View File

@ -55,7 +55,7 @@ class OSGUTIL_EXPORT SceneView : public osg::Referenced
else
{
// ensure that _viewport is always valid.
_viewport = new osg::Viewport;
_viewport = osgNew osg::Viewport;
}
}

View File

@ -168,9 +168,11 @@ int main( int argc, char **argv )
for(int i=1;i<argc;++i) commandLine.push_back(argv[i]);
// create the viewer and the model to it.
osgGLUT::Viewer viewer;
osgGLUT::Viewer& viewer = *(osgNew osgGLUT::Viewer);
viewer.setWindowTitle(argv[0]);
// configure the viewer from the commandline arguments, and eat any
// parameters that have been matched.
viewer.readCommandLine(commandLine);

View File

@ -502,12 +502,14 @@ sMStats m_getMemoryStatistics()
else ++numNotMatching;
}
if (numMatching>0)
if (numMatching>0 && !allocUnit->printedOutUnintializedInfo)
{
// possible unitialized data?
std::cout<<"possible uninitilized memory numMatching="<<numMatching<<" numNotMatching="<<numNotMatching<<std::endl;
std::cout<<" allocationNumber="<<allocUnit->allocationNumber<<" sourceFile '"<<allocUnit->sourceFile<<"' sourceLine="<<allocUnit->sourceLine<<std::endl;
allocUnit->printedOutUnintializedInfo=true;
return false;
}
return true;

View File

@ -117,7 +117,8 @@ Viewer::Viewer()
_initialTick = _timer.tick();
_frameTick = _initialTick;
frRate=0; // added by gwm to display fram Rate smoothed
_lastFrameTick = _initialTick;
frRate=0;
_focusedViewport = 0; // The viewport with mouse/keyboard focus
@ -125,6 +126,19 @@ Viewer::Viewer()
_frameStamp = osgNew osg::FrameStamp;
_displaySettings = osgNew osg::DisplaySettings;
}

View File

@ -82,7 +82,6 @@ CullVisitor::CullVisitor()
//_tsm = LOOK_VECTOR_DISTANCE;
_tsm = OBJECT_EYE_POINT_DISTANCE;
_computeNearFar = COMPUTE_NEAR_FAR_USING_BOUNDING_VOLUMES;
_computed_znear = FLT_MAX;
_computed_zfar = -FLT_MAX;
@ -93,6 +92,11 @@ CullVisitor::CullVisitor()
_numFramesToKeepImpostorSprites = 10;
_impostorSpriteManager = osgNew ImpostorSpriteManager;
_currentRenderGraph = NULL;
_currentRenderBin = NULL;
_currentReuseRenderLeafIndex=0;
}