opensim-org / opensim-core

SimTK OpenSim C++ libraries and command-line applications, and Java/Python wrapping.
https://opensim.stanford.edu
Apache License 2.0
783 stars 316 forks source link

Make Object::_document RAII-safe #3670

Closed adamkewley closed 8 months ago

adamkewley commented 8 months ago

Fixes nit

Brief summary of changes

Testing I've completed

Looking for feedback on...

CHANGELOG.md (choose one)


This change is Reviewable

adamkewley commented 8 months ago

LGTM 👍

Thanks for reading into this @tkuchida - I'll merge it after I do one last check on setDocument: one thing I'm realizing is that setDocument's old semantics are purely referential/leaky whereas the new one assumes control over whatever it receives, which might alter behavior

tkuchida commented 8 months ago

Sounds good, @adamkewley. (All tests are passing, so if a revision is required, I recommend beefing up :cow: the test cases to cover the difference.)

adamkewley commented 8 months ago

All uses of setDocument in the opensim-core tree are fine. E.g.:

Quick search through a spattering of open-source OpenSim API projects:

So I think it's safe to assume that adding unconditional ownership to the setDocument API (as in, the previous version would always leak any overwritten XMLDocument) is probably ok... probably.