Hello ROOTers,
The following code cause a seg fault because TPad instances seem to be deleted after the 1st loop of j is ended. Would you tell me what the problem is in the code? Using 5.27 and trunk on OS X 10.6 and SL5.
#include "TCanvas.h"
#include "TPad.h"
#include <iostream>
static const Int_t kSegmentN = 3;
static const Int_t kSampleN = 16;
void tmp()
{
TCanvas* can = new TCanvas("can", "can", 1200, 800);
can->Divide(4, 4, 1e-10, 1e-10);
TPad* pad_sigma[kSampleN];
TPad* pad_res[kSampleN];
for(Int_t i = 0; i < kSampleN; i++){
pad_sigma[i] = new TPad(Form("pad_sigma%02d", i), Form("pad_sigma%02d", i), 0, 0, 1, 1);
pad_res[i] = new TPad(Form("pad_res%02d", i), Form("pad_res%02d", i), 0, 0, 1, 1);
can->cd(i + 1);
gPad->SetBottomMargin(0.5);
pad_sigma[i]->SetMargin(0.1, 0.1, 0.3, 0.5);
pad_sigma[i]->SetFillStyle(0);
can->cd(i + 1);
pad_res[i]->SetMargin(0.1, 0.1, 0.1, 0.7);
pad_res[i]->SetFillStyle(0);
} // i
for(Int_t i = 0; i < kSegmentN; i++){
for(Int_t j = 0; j < kSampleN; j++){
can->cd(j + 1); gPad->DrawFrame(0, 0, 1, i + 1); pad_sigma[j]->Draw(); pad_sigma[j]->cd(); gPad->DrawFrame(0, 0, 1, i + 1); pad_res[j]->Draw(); pad_res[j]->cd(); gPad->DrawFrame(0, 0, 1, i + 1);
Regards,
-- OKUMURA, Akira oxon@{astro.isas.jaxa.jp,stanford.edu} Institute of Space and Astronautical Science (ISAS/JAXA) Now at KIPAC/SLAC/Stanford Varian Physics #306 382 Via Pueblo Mall, MC 406 Stanford, CA94305 TEL 650-736-0971/FAX 650-724-5065 Skype : okumura.akiraReceived on Fri Sep 03 2010 - 00:00:22 CEST
This archive was generated by hypermail 2.2.0 : Fri Sep 03 2010 - 11:50:01 CEST