class Container
{
public:
SimpleContainer();
~SimpleContainer();
private:
NodePath* m_pModelNodePath;
};
The destructor uses NodePath::remove_node() to remove the renderer’s reference to m_pModelNodePath. Since I don’t like memory leaks I would like to make sure the object itself (so the node to which m_pModelNodePath points) is also deleted. I should not call
delete m_pModelNodePath;
since I cannot be sure there are no more pointers to it (e.g. if I extend the above code with a get_node_path() method). So I have to be sure it will be deleted automatically later on.
The documentation at http://www.panda3d.org/apiref.php?page=NodePath#removeNode states the node will not only be removed from the renderer but also deleted entirely if there are no more pointers to it. Will it also be deleted in the future (once the condition is met) ? Since NodePath does not inherit from ReferenceCount I cannot simply use
PT(NodePath) ...
(I get an error saying NodePath does not have the function “_ref()” )
I cannot check if the node is deleted since it the node will remain alive as long as I keep any pointers to it and once I’ve thrown away all of its pointers (so it will be deleted) I cannot check for its existence any more.
Does the panda framework take care of this node in terms of deleting it once there are no more pointers to it ? Can I rely on this to happen or do I have to supply some flags/options/conditions ?