The following code crashes if I run the ringer() function. Strangely enough, if I open any canvas first and close it, it will work. Alternatively, commenting out the extraneous “for” loop accomplishes the same.
void sDraw (TText *t)
{
const char canvasName[] = "c1";
TCanvas *c;
if (gROOT->FindObject(canvasName) == NULL) {
c = new TCanvas(canvasName, canvasName);
} else c = (TCanvas*)gROOT->FindObject(canvasName);
t->Draw();
}
void ringer( )
{
// TCanvas *c1 = new TCanvas("c1","threshold finding", 200,10,1200,600);
TText *t = new TText(0.5,0.5,"Hello World");
for (int i=0; i < 1; i++ ) {
sDraw(t);
}
}