From 9092e48ce13e1de83d0e76076dd5d9b2a71887d7 Mon Sep 17 00:00:00 2001 From: 2xB <31772910+2xB@users.noreply.github.com> Date: Wed, 17 Apr 2024 13:18:13 +0200 Subject: [PATCH] KSComponentMath: Fix segfault during destruction (#103) * KSComponentMath: Fix segfault during destruction * KSComponentMath: Revert changing the copy constructor --- Kassiopeia/Objects/Include/KSComponentMath.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Kassiopeia/Objects/Include/KSComponentMath.h b/Kassiopeia/Objects/Include/KSComponentMath.h index 1f4fcf69e..6d2f879c2 100644 --- a/Kassiopeia/Objects/Include/KSComponentMath.h +++ b/Kassiopeia/Objects/Include/KSComponentMath.h @@ -52,7 +52,8 @@ template class KSComponentMath : public KSComponent } // initialize function once, parameters are updated every PushUpdate call - fFunction = std::make_shared("(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& aCopy) : KSComponent(aCopy), @@ -136,7 +137,7 @@ template class KSComponentMath : public KSComponent std::vector fParents; XValueType fResult; std::string fTerm; - std::shared_ptr fFunction; + TF1* fFunction; }; } // namespace Kassiopeia