Skip to content

Commit 256881d

Browse files
committed
[core] Disable the TDirectory::Append warning when using the same object.
It makes sense when a different object with the same name is registered (the old object will leak), but if the object is identical, the replacement is like a no-op.
1 parent b873a20 commit 256881d

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

core/base/src/TDirectory.cxx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,8 +207,10 @@ void TDirectory::Append(TObject *obj, Bool_t replace /* = kFALSE */)
207207
if (replace && obj->GetName() && obj->GetName()[0]) {
208208
TObject *old;
209209
while (nullptr != (old = GetList()->FindObject(obj->GetName()))) {
210-
Warning("Append","Replacing existing %s: %s (Potential memory leak).",
211-
obj->IsA()->GetName(),obj->GetName());
210+
if (obj != old) {
211+
Warning("Append","Replacing existing %s: %s (Potential memory leak).",
212+
obj->IsA()->GetName(),obj->GetName());
213+
}
212214
ROOT::DirAutoAdd_t func = old->IsA()->GetDirectoryAutoAdd();
213215
if (func) {
214216
func(old,nullptr);

0 commit comments

Comments
 (0)