Re: TDirectory problem

Rene Brun (Rene.Brun@cern.ch)
Sat, 09 Jan 1999 18:44:23 +0100


Nick van Eijndhoven wrote:
>
> Dear ROOTers,
> I encountered the following crash in ROOT 2.20/06 on windows95.
>
> I have a class Aap in which
>
> protected:
> TH1F* histo;
> private:
> TDirectory* fDir;
>
> are datamembers.
> In the default constructor I do
>
> Aap::Aap()
> {
> fDir=gDirectory->mkdir("Aap","test directory");
> histo=0;
> }
>
> whereas I have also the public memberfunctions
>
> void Aap::Fill()
> {
> fDir->cd();
> histo=new TH1F(........);
> .... // some code to fill the histogram
> }
> void Aap::Dir()
> {
> fDir->ls();
> }
>
> To test my code I have the following ROOT macro
>
> // macro test.C
> {
> gSystem->Load("Aap.dll");
>
> Aap p;
> p.Fill();
> Aap q;
> q.Fill();
> }
>
> The following ROOT session crashes :
>
> Root> .x test.C
> Root> q.Dir() // works ok
> Root> p.Dir() // ROOT crashes with a pagefault in ROOT_BASE
>
> when I use
> Root> gDirectory->ls()
>
> it also shows me only the directory for q.
>
> I have the feeling that the problem is related to the fact that
> I create 2 directories with the same name by creating 2 objects
> of the same class.
>
> Can anyone tell me what is wrong here and how I can cure it ?
> --

Hi Nick,
I cannot reproduce this problem.
It is normal that gDirectory->ls() shows only the last level.
That's where you are.
You can do at the end
gDirectory->cd("..");
gDirectory->ls(); // this will show you the 2 levels

Rene