Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[graf] Warn user about automatic overwrite of TCutG if same name #17553

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
21 changes: 18 additions & 3 deletions graf2d/graf/src/TCutG.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,12 @@ TCutG::TCutG(const char *name, Int_t n)
fObjectX = nullptr;
fObjectY = nullptr;
SetName(name);
delete gROOT->GetListOfSpecials()->FindObject(name);
auto obj = gROOT->GetListOfSpecials()->FindObject(name);
if (obj) {
Warning("TCutG","Replacing existing %s: %s (Potential memory leak).",
obj->IsA()->GetName(),obj->GetName());
delete obj;
}
gROOT->GetListOfSpecials()->Add(this);

// Take name of cut variables from pad title if title contains ":"
Expand Down Expand Up @@ -164,7 +169,12 @@ TCutG::TCutG(const char *name, Int_t n, const Float_t *x, const Float_t *y)
fObjectX = nullptr;
fObjectY = nullptr;
SetName(name);
delete gROOT->GetListOfSpecials()->FindObject(name);
auto obj = gROOT->GetListOfSpecials()->FindObject(name);
if (obj) {
Warning("TCutG","Replacing existing %s: %s (Potential memory leak).",
obj->IsA()->GetName(),obj->GetName());
delete obj;
}
gROOT->GetListOfSpecials()->Add(this);

// Take name of cut variables from pad title if title contains ":"
Expand Down Expand Up @@ -205,7 +215,12 @@ TCutG::TCutG(const char *name, Int_t n, const Double_t *x, const Double_t *y)
fObjectX = nullptr;
fObjectY = nullptr;
SetName(name);
delete gROOT->GetListOfSpecials()->FindObject(name);
auto obj = gROOT->GetListOfSpecials()->FindObject(name);
if (obj) {
Warning("TCutG","Replacing existing %s: %s (Potential memory leak).",
obj->IsA()->GetName(),obj->GetName());
delete obj;
}
gROOT->GetListOfSpecials()->Add(this);

// Take name of cut variables from pad title if title contains ":"
Expand Down
Loading