From cf312c2b2e8c4a26093c005ec63cf04bd3f4d7fd Mon Sep 17 00:00:00 2001 From: Christian Tacke <58549698+ChristianTackeGSI@users.noreply.github.com> Date: Mon, 22 Apr 2024 09:14:47 +0200 Subject: [PATCH] fix: Properly clean up TList in FairGeoSet FairGeoSet has non-owning references inside a TList to FairGeoNodes. When the dtor of FairGeoSet is called, those FairGeoNodes might already have been destroyed. Calling `Clear` with `"nodelete"` will just remove all the references without touching them. --- fairroot/geobase/FairGeoSet.cxx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/fairroot/geobase/FairGeoSet.cxx b/fairroot/geobase/FairGeoSet.cxx index 0f97a2fe59..cc1e4c0b3f 100644 --- a/fairroot/geobase/FairGeoSet.cxx +++ b/fairroot/geobase/FairGeoSet.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -55,6 +55,12 @@ FairGeoSet::FairGeoSet() FairGeoSet::~FairGeoSet() { // Destructor + if (volumes && !volumes->IsOwner()) { + // destructing a TList that doesn't own its contents + // still touches the objects inside, even if they're + // already destroeyed + volumes->Clear("nodelete"); + } delete volumes; volumes = 0; delete modules;