Skip to content

Ownership semantics of FairRootManager::GetObject #1346

@ChristianTackeGSI

Description

@ChristianTackeGSI

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).

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions