Started by this discussion: #1340 (comment)
FairRootManager::GetObject returns a TObject*. It is not obvious, whether this pointer is an owning or non-owning pointer.
Some code assumes it to be owning and consequently deletes the object at the end. Others don't.
The current implementation of this member function highly suggests that it returns non-owning pointers, because it usually returns copies of pointers (for example stored in fObj2–see little cleanup in #1343). @rbx came to this conclusion in the above mentioned discussion and I fully agree.
First the intended semantics should be clearly documented.
If it should return a non-owning pointer, then all callers should be analyzed to no longer delete the received pointer and FairRootManager should clean them up at the end (since it is owning the pointer).
If it should return an owning pointer, we should have an API that returns a unique_ptr (possibly already casted to the correct type).
FairRoot/fairroot/online/steer/FairRunOnline.cxx
Line 221 in 12f519f
FairRootManager::GetObjectfunction #1353Started by this discussion: #1340 (comment)
FairRootManager::GetObjectreturns aTObject*. It is not obvious, whether this pointer is an owning or non-owning pointer.Some code assumes it to be owning and consequently
deletes the object at the end. Others don't.The current implementation of this member function highly suggests that it returns non-owning pointers, because it usually returns copies of pointers (for example stored in
fObj2–see little cleanup in #1343). @rbx came to this conclusion in the above mentioned discussion and I fully agree.First the intended semantics should be clearly documented.
If it should return a non-owning pointer, then all callers should be analyzed to no longer
deletethe received pointer and FairRootManager should clean them up at the end (since it is owning the pointer).If it should return an owning pointer, we should have an API that returns a unique_ptr (possibly already casted to the correct type).