TApplication crash upon "Quit root"

While running the following code

int main()
{
  TApplication app("myapp", 0, 0);
  TFile * f = TFile::Open("file.root");
  TH1 * histo = (TH1*) f -> Get("histogram");
  TCanvas c;
  histo -> Draw();
  app.Run(kTRUE);
  f -> Close();
  app.Terminate();                                                                                                                                                                                      
}

I exit from the program by clicking on canvas File -> "Quit Root" as prescribed in Return from TApplication when there is no canvas

closing_tapplication_cropped

However, this causes a crash. The reasons are clear - TFile::Close() is called after having exited Root.
How to approach this problem?

Are you using the latest master branch or v6-12-00-patches branch of ROOT? If yes, I’d recommend you to try using the v6-11-02 tag instead. The current master has some problems currently being addressed for the next release. Thanks.

I am using ROOT 6.06/09. I am not sure if I can change the tag - the Root version I am using is embedded into CMSSW.

Nevermind. Then the problem is different. Looking at your code, you can probably simply remove the lines f->Close() and app.Terminate(). ROOT itself will take care of that once you exit via the menu.

No. There is still a crash after commenting out f->Close() and app.Terminate().

TApplication dies when Run(kTRUE)

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.