Gepetto / gepetto-viewer

Graphical Interface for Pinocchio and HPP.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Meshes are never deleted

florent-lamiraux opened this issue · comments

To display an octree, I create an obj file that I then load through CORBA by calling method WindowsManager::addMesh.
This function calls LeafNodeCollada::create that calls LeafNodeCollada::init.

After this line,

collada_ptr_ = osgDB::readNodeFile(collada_file_path_,options);

the number of referenceCount of collada_ptr_ is 2 although I expect it to be 1.
As a consequence, in the desctructor the test
if (collada_ptr_->referenceCount() == 2) {

is always false and the object is never removed from the cache.
As a consequence, reloading the object after deleting the node displayes the previous object eventhough the files has been modified.

I tried to add a method to explicitely remove the object from the cache when deleting the node, but it does not solve the problem.
I also tried to decrement manually the counter by adding

collada_ptr_->unref()

after line 110 above, but I got a segmentation fault.

Does anyone know whether it is normal that the reference count is equal to 2 just after creating the object ?

I would say yes. One reference hold by the cache, one hold by collada_ptr_.

You are right. The problem is that the object does not seem to be removed from the cache here:
https://github.com/florent-lamiraux/gepetto-viewer/blob/ec82cb0c80082c4c4c13195705aa2ccae3439216/src/leaf-node-collada.cpp#L459
The number of reference counts is the same before and after this line.
I am investigating.

I think we have to store the option used to load the mesh and pass it to removeFromObjectCache.

Looking at OpenSceneGraph code you are probably right. I will try.

Solved by #183.