HomerSimpson wrote:
> My project is throwing an occasional "unhandled win32 exception" error and 
> I've been trying to figure out why.


One thing you should check is if you have any raw C++ pointers pointing to 
objects that are also pointed to by ref_ptr's. Accessing the object through the 
raw pointer after that the ref_ptr's have gone out of scope is illegal since 
the object is automaticly destroyed when the last ref_ptr goes out of scope.

Notice that since OSG uses ref_ptr's in most places any object that you add to 
a scenegraph will most likely be referenced by a ref_ptr. You should therefore 
try to avoid using raw pointers to such objects. It's safer to use ref_ptr's.

Example: the following will fail


Code:
osg::Node* myTransform = new osg::MatrixTransform();
{
osg::ref_ptr< osg::Group > myGroup = new osg::Group();
myGroup->addChild(myTransform);
}
myTransform->someMethod(); // Wrong. Object has been deleted.




In the example above replace the first line with:

Code:
osg::ref_ptr< osg::Node > myTransform = new osg::MatrixTransform();


and use myTransform.get() inside the addChild call.

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=23809#23809





_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to