Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions core/base/src/TDirectory.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,10 @@ void TDirectory::Append(TObject *obj, Bool_t replace /* = kFALSE */)
if (replace && obj->GetName() && obj->GetName()[0]) {
TObject *old;
while (nullptr != (old = GetList()->FindObject(obj->GetName()))) {
Warning("Append","Replacing existing %s: %s (Potential memory leak).",
obj->IsA()->GetName(),obj->GetName());
if (obj != old) {
Warning("Append", "Replacing existing %s: %s (Potential memory leak).", obj->IsA()->GetName(),
obj->GetName());
}
ROOT::DirAutoAdd_t func = old->IsA()->GetDirectoryAutoAdd();
if (func) {
func(old,nullptr);
Expand Down
6 changes: 6 additions & 0 deletions tree/treeplayer/src/TSelectorDraw.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -578,6 +578,7 @@ void TSelectorDraw::Begin(TTree *tree)
} else {
hist = new TH1D(hname, htitle.Data(), fNbins[0], fVmin[0], fVmax[0]);
}
hist->SetDirectory(gDirectory);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note, this is not 'strictly' equivalent to the behavior of AddDirectoryStatus for histograms:

   if (TH1::AddDirectoryStatus()) {
      fDirectory = gDirectory;
      if (fDirectory) {
         fFunctions->UseRWLock();
         fDirectory->Append(this,kTRUE);
      }
   }

I.e. in the switch we 'lose' the part that make the histogram's list of function thread safe.

hist->SetLineColor(fTree->GetLineColor());
hist->SetLineWidth(fTree->GetLineWidth());
hist->SetLineStyle(fTree->GetLineStyle());
Expand Down Expand Up @@ -661,6 +662,7 @@ void TSelectorDraw::Begin(TTree *tree)
} else {
hp = new TProfile(hname, htitle.Data(), fNbins[1], fVmin[1], fVmax[1], "");
}
hp->SetDirectory(gDirectory);
if (!hkeep) {
hp->SetBit(kCanDelete);
if (!opt.Contains("goff")) hp->SetDirectory(nullptr);
Expand Down Expand Up @@ -689,6 +691,7 @@ void TSelectorDraw::Begin(TTree *tree)
} else {
h2 = new TH2D(hname, htitle.Data(), fNbins[1], fVmin[1], fVmax[1], fNbins[0], fVmin[0], fVmax[0]);
}
h2->SetDirectory(gDirectory);
h2->SetLineColor(fTree->GetLineColor());
h2->SetLineWidth(fTree->GetLineWidth());
h2->SetLineStyle(fTree->GetLineStyle());
Expand Down Expand Up @@ -803,6 +806,7 @@ void TSelectorDraw::Begin(TTree *tree)
} else {
hp = new TProfile2D(hname, htitle.Data(), fNbins[2], fVmin[2], fVmax[2], fNbins[1], fVmin[1], fVmax[1], "");
}
hp->SetDirectory(gDirectory);
if (!hkeep) {
hp->SetBit(kCanDelete);
if (!opt.Contains("goff")) hp->SetDirectory(nullptr);
Expand All @@ -826,6 +830,7 @@ void TSelectorDraw::Begin(TTree *tree)
h2 = (TH2F*)fOldHistogram;
} else {
h2 = new TH2F(hname, htitle.Data(), fNbins[1], fVmin[1], fVmax[1], fNbins[0], fVmin[0], fVmax[0]);
h2->SetDirectory(gDirectory);
h2->SetLineColor(fTree->GetLineColor());
h2->SetLineWidth(fTree->GetLineWidth());
h2->SetLineStyle(fTree->GetLineStyle());
Expand Down Expand Up @@ -859,6 +864,7 @@ void TSelectorDraw::Begin(TTree *tree)
} else {
h3 = new TH3D(hname, htitle.Data(), fNbins[2], fVmin[2], fVmax[2], fNbins[1], fVmin[1], fVmax[1], fNbins[0], fVmin[0], fVmax[0]);
}
h3->SetDirectory(gDirectory);
h3->SetLineColor(fTree->GetLineColor());
h3->SetLineWidth(fTree->GetLineWidth());
h3->SetLineStyle(fTree->GetLineStyle());
Expand Down
Loading