Skip to content

Commit

Permalink
Reverted OpenSim::Controller fix to use constructProperties (#3247)
Browse files Browse the repository at this point in the history
  • Loading branch information
adamkewley committed Feb 24, 2023
1 parent bd8b11b commit cd4e406
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
21 changes: 17 additions & 4 deletions OpenSim/Simulation/Control/Controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,7 @@ Controller::Controller() :
_numControls{0},
_actuatorSet{}
{
setAuthors("Ajay Seth, Frank Anderson, Chand John, Samuel Hamner");
constructProperty_enabled(true);
constructProperty_actuator_list();
_actuatorSet.setMemoryOwner(false);
constructProperties();
}

Controller::Controller(Controller const& src) :
Expand All @@ -62,11 +59,16 @@ Controller::Controller(Controller const& src) :
_numControls{src._numControls},
_actuatorSet{}
{
// care: the reason this custom copy constructor exists is to prevent
// a memory leak (#3247)
_actuatorSet.setMemoryOwner(false);
}

Controller& Controller::operator=(Controller const& src)
{
// care: the reason this custom copy assignment exists is to prevent
// a memory leak (#3247)

if (&src != this)
{
static_cast<ModelComponent&>(*this) = static_cast<ModelComponent const&>(src);
Expand All @@ -86,6 +88,17 @@ Controller::~Controller() noexcept = default;
//_____________________________________________________________________________
//_____________________________________________________________________________

/**
* Connect properties to local pointers.
*/
void Controller::constructProperties()
{
setAuthors("Ajay Seth, Frank Anderson, Chand John, Samuel Hamner");
constructProperty_enabled(true);
constructProperty_actuator_list();
_actuatorSet.setMemoryOwner(false);
}

void Controller::updateFromXMLNode(SimTK::Xml::Element& node,
int versionNumber) {
if(versionNumber < XMLDocument::getLatestVersion()) {
Expand Down
3 changes: 3 additions & 0 deletions OpenSim/Simulation/Control/Controller.h
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,9 @@ OpenSim_DECLARE_ABSTRACT_OBJECT(Controller, ModelComponent);
// the (sub)set of Model actuators that this controller controls */
Set<const Actuator> _actuatorSet;

// construct and initialize properties
void constructProperties();

//=============================================================================
}; // END of class Controller

Expand Down

0 comments on commit cd4e406

Please sign in to comment.