Hi,

I didn't understand exactly what you need, but another way to be notified when an object is about to being deleted is to derive your own class from osg::Observer, and make it point to the node you're interested in. At deletion time the method "virtual void objectDeleted(void*)" will be called and you can do whatever you need.
This is used in observer_ptr class.

Cheers,
Ricky


On 24/06/2009 22.24, Ismail Pazarbasi wrote:
On Wed, Jun 24, 2009 at 10:12 PM, Judd Tracy<[email protected]>  wrote:
You could always attach a create your own DeleteHandler and attach it to the
node, but I don't know if that will help you other then letting you know it
is going to be deleted.

On Wed, Jun 24, 2009 at 11:58 AM,<[email protected]>  wrote:
What is the easiest way to determine if a particular node is being deleted
from memory? I have a relatively complex scene and part of the scene needs
to be deleted and reconstructed at times. I'm concerned there might be a
memory leak and that some of my nodes are not being freed because we aren't
using ref_ptr where we need them.

Paul P.



_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org



Did you try:
template<typename T>
struct MyObj : T
{
   ~MyClass()
   {
     // handle deletion; output something to stderr, console, debugger,
file, etc.
   }
};


{
   osg::ref_ptr<MyObj<osg::Group>  >  pobj = new osg::Group;
  // use pobj
} // should call destructor here.

Instead of a template class, you may derive directly from
osg::Referenced or osg::Object as the most common base types, but then
you lose full functionality of actual type and need to cast.

I didn't test the code (have no osg neither a compiler on my Omnia
PDA), but I'd expect that to work regardless of project, as long as
base type has a virtual destructor and gets deleted (in case delete is
applied onto pointer to base type, which is the case in osg).

Ismail
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to