opensim-org / opensim-core

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

Fix getConnectee throwing if called during finalizeConnections #3687

Closed adamkewley closed 5 months ago

adamkewley commented 5 months ago

Fixes an issue I'm having with SocketDefinedFrames implementation (upcoming PR).

Effectively, the bug is that:

So, in the edge-case that you:

The solution is PRed, and it effectively relaxes sockets such that they work fine even if you don't call finalizeConnection on them. This effectively downgrades finalizeConnection from "hard requirement for using a socket" to "performance-enhancing requirement".

Brief summary of changes

Testing I've completed

Looking for feedback on...

CHANGELOG.md (choose one)


This change is Reviewable

adamkewley commented 5 months ago

Need to check what's the deal with MacOS/Ubuntu

adamkewley commented 5 months ago

@nickbianco this is ready for review if you're willing!

The function was moved to Component.h, because I noticed that other component-dependent templated functions for Socket<T> appear there. A test (for the failing behavior) was also commented out (because it's not longer a strictly failing case, but a slow one).

Hopefully, this relaxation of the connection finalization behavior is acceptable? I think there's some (reasonable) debate over whether it should be allowed (because it may encourage people to skip finalizing connections), but the counterpoint is that any code that (e.g.) calls buildSystem will be finalized anyway.