TStyle bug?

From: Philip Rodrigues <philip.rodrigues_at_lincoln.ox.ac.uk>
Date: Fri, 28 Mar 2008 09:30:57 +0000


Hi RootTalk,
I've noticed an odd crash with TStyle. It's easily worked around, so I guess you might not call it a bug, but I've attached a testcase to demonstrate. Run create_rootfile.C to create a suitable .root file, and read_canvas.C to see the crash.

What happens is that if you obtain a pointer to a canvas from a file, then call gStyle->SetOptStat(), ROOT crashes in TGX11::DrawBox. I think this is because obtaining the pointer sets gPad, even though the canvas isn't drawn. In TStyle::SetOptStat, there is:

if (gPad) {

	...
	gPad->Modified(); gPad->Update();

}

which I suppose crashes when the gPad hasn't yet been drawn.

The simple workaround for me is to Draw() the canvas before calling gStyle->SetOptStat(), or make the call to gStyle before obtaining the TCanvas pointer, but it's easy to forget, and hard to track down why the crash occurs.

Maybe setting gPad only when the canvas is drawn would prevent this crash?

Regards,
Philip

Received on Fri Mar 28 2008 - 10:31:02 CET

This archive was generated by hypermail 2.2.0 : Fri Mar 28 2008 - 17:50:01 CET