-
Notifications
You must be signed in to change notification settings - Fork 342
Open
Labels
issue: bug (major)Critical bug affecting everyone: not working, performances or accuracy degradedCritical bug affecting everyone: not working, performances or accuracy degraded
Description
Description
Components that have slaves (via l_slaves) do not have their destructors called during scene unload, even though cleanup() is called correctly.
Root Cause
BaseObject::l_slaves is defined with FLAG_STRONGLINK:
// BaseObject.h:134
typedef MultiLink<BaseObject, BaseObject, BaseLink::FLAG_DOUBLELINK|BaseLink::FLAG_STRONGLINK> LinkSlaves;When a component (e.g., TetrahedronFEMForceField) has slaves (e.g., Stiffness_matrix, Damping_matrix created by the matrix assembly system), these strong references are never released during cleanup. This prevents the reference count from reaching zero, so the destructor is never called.
Steps to Reproduce
- Create a scene with TetrahedronFEMForceField (or any component that acquires slaves)
- Run with batch GUI: runSofa -g batch scene.scn
- Quit normally
- Observe that TetrahedronFEMForceField::~TetrahedronFEMForceField() is never called, while cleanup() is called
Expected Behavior
The destructor should be called after cleanup() when the scene is unloaded.
Workaround
Manually removing slaves in cleanup() fixes the issue:
void cleanup() override
{
while (!this->l_slaves.empty())
{
this->removeSlave(this->l_slaves.getValue().front());
}
Inherit1::cleanup();
}Suggested Fix
BaseObject::cleanup() should automatically remove all slaves:
void BaseObject::cleanup()
{
while (!l_slaves.empty())
{
removeSlave(l_slaves.getValue().front());
}
}Metadata
Metadata
Assignees
Labels
issue: bug (major)Critical bug affecting everyone: not working, performances or accuracy degradedCritical bug affecting everyone: not working, performances or accuracy degraded