The setup : a framework and a module; the latter adds lines to a histo which is then handled by the framework. The framework might, or might not, reset the histogram.
The problem : if the framework resets the histo, the lines are removed and deleted. When the module gets back control of the histos, he needs to update the lines but they might not be there anymore.
Question : is it possible to tell the histo that he should not own the lines ? Ideally it should not touch them but at least I would like that it does not delete them. I tried to do h->GetListOfFunctions()->SetOwner(false) and
line->ResetBit(kCanDelete) to no avail.
I can reproduce what you describe here with the following macro.
I confirm that the two solutions you tried (commented) do not work.
TH1F *h = new TH1F("h","h",100,-4,4);
TLine *line = new TLine(-3.180516,325.5566,3.309456,83.87704);
TCanvas *C = new TCanvas("C","C",800,1000);
I have no solution for the time being…
Thank you for the quick confirmation. I will work around for the time being.
I think I found an easy workaround. In my example do:
Good idea, thank you.
I will use this. Do you want to create a JIRA issue any ways ?
I am not sure it is a bug or an issue as the TH1 destructor is implemented this way explicitly.
So I do not think a Jira report is needed unless you think another behavior would be better,
and in that case you can submit a request for new developments.