If you absolutely have to keep a regular pointer to something derived from Referenced, then you should at least set up an observer so that you can be notified when the memory gets deleted (and then NULL out your pointer). See osg::Referenced::addObserver().
Another (cleaner) way to handle this situation would be to create a wrapper class that contains a ref_ptr to your node, and pass a pointer to your wrapper class over the ActiveX interface. -Paul > -----Original Message----- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of > [EMAIL PROTECTED] > Sent: Wednesday, January 17, 2007 2:38 AM > To: [email protected] > Subject: RE: [osg-users] ref_ptr and Geode/Geometry > > Hi All, > > Sorry to chip in here, but this topic relates to a concern > I'm having over my wrapping of osg within an ActiveX control. > Essentially within the control I create osg::Nodes, some are > ref_ptr'd some aren't. As a consequence of what I want to do > with these nodes I need to pass a pointer to them back across > the ActiveX COM interface into the container, however I don't > want the container to have to know anything about OSG. > > The "solution" I've implemented is merely to take the address > of the node and pass that back as an unsigned long. However > this gives no "thought" to the reference count issues for the node. > > Everything seems to work, however I have an unease about > whether the pointer that I return (unsigned long containing > the address of the node) is valid because its reference > hasn't been decremented (though why I'm not sure) or whether > I've been lucky till now not to have the node structure > memory being corrupted by some other calls - in effect the > memory having been released back to the heap. > > Any thoughts why I'm still flying might help me sleep at night :-) > > Thanks > > Neil > > > _______________________________________________ > osg-users mailing list > [email protected] > http://openscenegraph.net/mailman/listinfo/osg-users > http://www.openscenegraph.org/ _______________________________________________ osg-users mailing list [email protected] http://openscenegraph.net/mailman/listinfo/osg-users http://www.openscenegraph.org/
