I am experimenting a little with the Sketcher code.
Using python, when you add a constraint to the Sketcher, you create it and pass it to sketch.addConstraint(). The C++ counterpart of the addConstraint() method duplicates (clones) the constraint to an instance that does not have a python counter part.
I am trying to simply keep the reference instead of copying it. But I don't want to get a dangling reference when the python object is destructed. I realize that I probably have to increase some reference counter somewhere.
So, I would like to ask what is the proper way to do that. What is the proper way to deal with references to python objects and avoid them getting garbage collected?
How to deal with objects that live in C++ and Python?
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Be nice to others! Respect the FreeCAD code of conduct!
- andrecaldas
- Posts: 301
- Joined: Fri Jan 27, 2023 8:45 pm
- Contact: