There is something weird with TCanvas. When typing in the interpreter :
root [0] TCanvas *can = new TCanvas();
root [1] can->Close();
everything works fine : the canvas opens then closes itself.
But when running or compiling the following macro :
int test()
{
int h;
cin>>h;
TCanvas *can=new TCanvas();
cout<<"Canvas should be created !!!"<<endl;
cin>>h;
can->Close();
cout<<"Canvas must be closed !!!"<<endl;
cin>>h;
cout<<"Canvas still there ???"<<endl;
cin>>h;
return 0;
}
the canvas is created while it should close itself, and will never close !!!
You must tell ROOT to process the pending events. Pending events
are executed when you type CR after a command or when the macro completes. Modify your script as follows
int test()
{
int h;
cin>>h;
TCanvas *can=new TCanvas();
gSystem->ProcessEvents();
cout<<"Canvas should be created !!!"<<endl>>h;
delete can; //can->Close();
gSystem->ProcessEvents();
cout<<"Canvas must be closed !!!"<<endl>>h;
cout<<"Canvas still there ???"<<endl>>h;
return 0;
}
Note that to post code like above, YOU MUST CLICK on the item “Disable HTML in this post”
[quote=“brun”]Note that to post code like above, YOU MUST CLICK on the item “Disable HTML in this post”[/quote]Thanks again, I didn’t notice that…