Skip to content

Commit

Permalink
KSComponentMath: Fix segfault during destruction (#103)
Browse files Browse the repository at this point in the history
* KSComponentMath: Fix segfault during destruction

* KSComponentMath: Revert changing the copy constructor
  • Loading branch information
2xB authored Apr 17, 2024
1 parent 39c8d69 commit 9092e48
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions Kassiopeia/Objects/Include/KSComponentMath.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ template<class XValueType> class KSComponentMath : public KSComponent
}

// initialize function once, parameters are updated every PushUpdate call
fFunction = std::make_shared<TF1>("(anonymous)", fTerm.c_str(), -1., 1.);
// Object is automatically managed and garbage collected by the global TROOT object (gROOT)
fFunction = new TF1("(anonymous)", fTerm.c_str(), -1., 1.);
}
KSComponentMath(const KSComponentMath<XValueType>& aCopy) :
KSComponent(aCopy),
Expand Down Expand Up @@ -136,7 +137,7 @@ template<class XValueType> class KSComponentMath : public KSComponent
std::vector<XValueType*> fParents;
XValueType fResult;
std::string fTerm;
std::shared_ptr<TF1> fFunction;
TF1* fFunction;
};

} // namespace Kassiopeia
Expand Down

0 comments on commit 9092e48

Please sign in to comment.