From 12337053079c201d914b9722c353ebfa2bcde7ea Mon Sep 17 00:00:00 2001 From: Sergey Linev Date: Wed, 6 Mar 2024 12:48:44 +0100 Subject: [PATCH] [thstack] fix copy constructor One have to register THStack in list of cleanups --- hist/hist/src/THStack.cxx | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/hist/hist/src/THStack.cxx b/hist/hist/src/THStack.cxx index c525a2402ab69..72b6e0c0353c1 100644 --- a/hist/hist/src/THStack.cxx +++ b/hist/hist/src/THStack.cxx @@ -347,11 +347,14 @@ THStack::THStack(const THStack &hstack) : fMaximum(hstack.fMaximum), fMinimum(hstack.fMinimum) { - if (hstack.GetHists()) { - TIter next(hstack.GetHists()); - TH1 *h; - while ((h=(TH1*)next())) Add(h); + { + R__LOCKGUARD(gROOTMutex); + gROOT->GetListOfCleanups()->Add(this); } + + TIter next(hstack.GetHists()); + while (auto h = static_cast(next())) + Add(h); } ////////////////////////////////////////////////////////////////////////////////