-
Notifications
You must be signed in to change notification settings - Fork 53
Closed
Labels
issue: bugSomething isn't workingSomething isn't working
Description
The issue is related to python reference holding in overridable classes.
Some binded have a valid behavior (eg: Controller) but other don't (Prefab/RawPrefab)
The problem can be reproduced with the follwing scene:
import Sofa
class MyController(Sofa.Core.Controller):
def __init__(self, *args, **kwargs):
Sofa.Core.Controller.__init__(self,*args,**kwargs)
print("Controller created")
def __del__(self):
print("Controller deleted")
class MyPrefab(Sofa.Core.RawPrefab):
def __init__(self, *args, **kwargs):
Sofa.Core.RawPrefab.__init__(self,*args,**kwargs)
print("Prefab created")
def __del__(self):
print("Prefab deleted")
def createScene(root):
root.addObject(MyController())
root.addChild(MyPrefab()) The expected behavior is demonstrated by overriding a Controller, and the broken is implmented by overriding a Prefab.
The MyPrefab's destructor is called (which means that the reference count down to zero), while the controller's one is not.
This is related probably related to PR: #74
(Adding manually an extra reference to the python object solve the problem but is clearly is not the solution... I wonder if this is due to a misunderstanding in how the py_shared_ptr in Bindin_Prefab.cpp)
Metadata
Metadata
Assignees
Labels
issue: bugSomething isn't workingSomething isn't working