Behaviour of TCanvas title in batch mode

Hello,

I’ve noticed that in batch mode, when creating a TCanvas, it defaults to having a title identical to the canvas name, even if they are specified differently in the constructor. Looking in the code this seems to depend on the fCanvasImp boolean, which gets its value depending on (amongst other things) the batch status.

Is this intended behaviour? I wish to create canvases in batch mode, write them to a root file, and then display them later. The title is some long descriptive text that I do not wish to have as the name.

code:
string canvasname;
string canvastitle;

fill strings

TCanvas *c1 = new TCanvas(canvasname.c_str(),canvastitle.c_str(),1000,1000);

Draw some histograms…

c1->Modified();
c1->Update();
c1->Write();

Thanks,
Scott.

The canvas title is displayed in the window title bar. By definition in batch mode you do not have any window … so you do not have any window title bar … so how do you see, in batch mode, that the canvas title is not correct ?
Can you provide a small running script (preferably C++) showing this issue ?

I’m sorry, I must not have been clear in my original post. I am using batch mode to create a root file for later examination using TBrowser or similar. I create the canvas, write it to the file, then open it with TBrowser at a later time.

The following script shows the issue:

void TCanvas_batch()
{
gROOT->SetBatch(kTRUE);
TFile *f = new TFile(“TCanvas_batch.root”,“RECREATE”);
TH1F *spec = new TH1F(“TestSpec”,“TestSpec”,10,0,9);

spec->FillRandom(“gaus”,1000);

TCanvas *c1 = new TCanvas(“Name”,“Title”);
spec->Draw();

c1->Write();
f->Write();
gROOT->SetBatch(kFALSE);
}

Note that the window title bar has the text “Name” and not “Title” in it (at least in my version 5.18.00). If, however, I comment out the SetBatch command, the window title bar then has “Title” written in it.

Thanks,
Scott.

Only when you execute the macro … if you then draw the canvas saved in the file in interactive mode it also has the title “Name”… yes that’s weird …

Now fixed in 6.08. Thanks for reporting.