"The THStack doesn't own the objects", yet it does!


I think that the documentation for the THStack is slightly misleading in the sense that it states :

although it does own the object pointed by fHistogram :

THStack::~THStack() { [snip] if (fStack) {fStack->Delete(); delete fStack;} delete fHistogram; // <--------------------------------- deletion of the histo !! fHistogram = 0; }

I agree that it doesn’t delete objects of the list, but yet the documentation made me believe it wouldn’t touch any of my objects. Adding a sentence to the doc would help.

Thank you,

fHistogram is created internally to draw the stack. It is not one of your objects.
If you do GetHistogram and want to keep the result after THStack has been deleted you should copy it. I think the documentation is right saying the stack does not own the object in the list.


But what if I use SetHistogram ?
Actually, I use SetHistogram with one of the histograms in the list. So indeed, I might have got confused. Or is it meant to be used in a different way ? Or not set by the user ?


Yes, using SetHistogram is a valid way to impose the limits. But surely it is not a good idea to use one of the histogram in the list. Better do a copy before. Still, the documentation is right: the list is untouched. Your case is a bit “on the edge”…

Ok, I understand better. I will rather make a copy of the histogram before setting it.

Thank you !