I am a bit fuzzy on reference pointers and am not certain why the
following is bad although I have a gut feeling as to why.
I have a class Derived which is derived from base class MY_D_REF which is
a descendant of osg::Referenced. Derived is also a direct decedent of
osgGA::GUIEventHandler.
class Derived : public MY_D_REF, public osgGA::GUIEventHandler,
class MY_D_REF : public osg::Referenced
Class MY_D_REF has a callback which uses a this * to pack its callback
data:
trans->setUserData(this);
trans->setUpdateCallback(new MyCallback);
//---------------------------------------------------------------
class MyCallback : public osg::NodeCallback {
public:
virtual void operator()(osg::Node *node, osg::NodeVisitor *nv) {
osg::ref_ptr<MY_D_REF> wp = dynamic_cast<MY_D_REF*>
(node->getUserData());
/--- do stuff --/
traverse(node, nv);
}
When Derived is destroyed at the end of the program, I get an access
violation (xmemory's (windoze) destructor template).
IF Derived is not derived from both classes, everything is okay.
or
IF I take out the callback, everything is okay.
When I say that everything is okay, I mean the program exits fine. I
understand that everything is not in fact okay.
Is this because of packing my callback with a this pointer and it's not
getting its count decreased? Is that bad mojo? Is there something special
I should be doing to decrease the reference the MY_D_REF object in its
destructor? I have the destructors protected for the derived classes. Or
is this a something that I might run into because multiple ancestors are
derived from osg::Referenced? I was worried about a possible circular
reference, so I took out reference pointers in the derived classes, but
the results were the same.
Thanks,
Keith
--
Keith Parkins U of R Center for Visual Science
[EMAIL PROTECTED] Meliora Hall, Room 236
office: (585) 275-3938 lab: (585) 275-2230
_______________________________________________
osg-users mailing list
[email protected]
http://openscenegraph.net/mailman/listinfo/osg-users
http://www.openscenegraph.org/