Re: [ROOT] Need advice with TString problem? - static as solution?

From: cstrato (cstrato@aon.at)
Date: Sat Dec 20 2003 - 16:42:55 MET


Dear Rene

Thank you, now I understand. I had the class definition:
class XSelector: public XAlgorithm {
    protected:
==>   Option_t  *fOption;
    public:
       XSelector();
       XSelector(const char *name, const char *type);
       virtual ~XSelector();

==>   void  SetOption(Option_t *opt) {fOption = opt;}
};

Now I have changed the type to: TString fOption;
and everything works.

Best regards
Christian


Rene Brun wrote:

> Hi Christian,
> 
> The fact that your system works with a static TString goes in the 
> direction of my remark in my previous mail. I have the impression that
> in your function you store a pointer to the string (instead of storing
> a pointer to a copy of the string). When the TString goes out of scope
> your pointer becomes a dangling pointer and you get the typical segm. 
> violation.
> 
> I cannot tell you more without having a 20 lines program reproducing 
> your problem, but I hope that my comment is sufficient for you to make
> further investigations.
> 
> Rene
> 



This archive was generated by hypermail 2b29 : Thu Jan 01 2004 - 17:50:17 MET