Re: TStyle bug?

From: Rene Brun <Rene.Brun_at_cern.ch>
Date: Fri, 28 Mar 2008 15:07:29 +0100


Thanks for reporting this special case. I have added a protection in TCanvas::Update (now in SVN)

Rene Brun

Philip Rodrigues wrote:
> 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 - 15:04:46 CET

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