TPad empty constructor causes ROOT crash

Linux RH 7.2, ROOT v. 3.05/05

ROOT crashes if I use the following piece of code:

TCanvas canvas(“c1”, “c1”);
TPad pad1;
pad1.SetPad( 0.02, 0.52, 0.98, 0.95 );

However, if I use another constructor, everything works well:

TCanvas canvas(“c1”, “c1”);
TPad pad1( “as”, “zx”, 0, 0, 1, 1 );
pad1.SetPad( 0.02, 0.52, 0.98, 0.95 );

Apparently the problem lies in the empty pointers to mother canvas and stuff like that. MY QUESTION IS: how do I define an array of TPads without using the empty constructor? Or is there another way to avoid these crashes?

Thanks.

I will investigate this problem. For sure a missing protection.
But here I have a remark.

In general, you should not create your TPads in the stack. When leaving your function, they will be automatically deleted,
probably not what you want.
use new TPad instead and make an array
of pointers TPad *pads[10];

Rene Brun

This problem still exists:

root [5] TCanvas can root [6] TPad pad1("pad1","pad1Title",0.02,0.02,0.98,0.48); root [7] pad1.ls() TPad fXlowNDC=0.02 fYlowNDC=0.02 fWNDC=0.96 fHNDC=0.46 Name= pad1 Title= pad1Title Option= root [8] TPad pad2; root [9] pad2.SetPad("pad2","pad2Title",0.02,0.02,0.98,0.48); root [10] pad2.ls() TPad fXlowNDC=0.02 fYlowNDC=0.02 fWNDC=0.96 fHNDC=0.46 Name= pad2 Title= pad2Title Option= Error: C++ exception caught (tmpfile)(1) (const void)0 *** Interpreter error recovered ***

Would it be better to divide the canvas then set pad sizes myself?

TPad is now protected (CVS head) when the default constructor is called and TPad functions are called.

Rene