This was seen when @gurchiek was using MATLAB to insert a new point into a PathPointSet created with clone().
clone() creates a new point that did not have a model or owner (hasModel() and hasOwner() were false). Then, using PathPointSet::insert() and finalizeConnections() made the Set take ownership, which can cause problems with MATLAB's garbage collector. Using markAdopted() fixed the issue in an isolated example.
We should consider adding this to one of our .i files (perhaps java_simulation.i?). Some things to note:
- If the object being inserted is non-const, we still might need to check if the Set has
getMemoryOwner() as true or false. https://simtk.org/api_docs/opensim/api_docs/classOpenSim_1_1Set.html#adf1da111571bb1f156da8ab169181a48
- If the object being inserted is const, we wouldn't need to check as it always makes a copy, but I'm not sure how/if MATLAB differentiates between these two methods anyway. https://simtk.org/api_docs/opensim/api_docs/classOpenSim_1_1Set.html#af79a11b57529978ce78c9dc28771bfe2
This was seen when @gurchiek was using MATLAB to insert a new point into a
PathPointSetcreated withclone().clone()creates a new point that did not have a model or owner (hasModel()andhasOwner()were false). Then, usingPathPointSet::insert()andfinalizeConnections()made the Set take ownership, which can cause problems with MATLAB's garbage collector. UsingmarkAdopted()fixed the issue in an isolated example.We should consider adding this to one of our .i files (perhaps java_simulation.i?). Some things to note:
getMemoryOwner()as true or false. https://simtk.org/api_docs/opensim/api_docs/classOpenSim_1_1Set.html#adf1da111571bb1f156da8ab169181a48