Hi, This is the expected behaviour in C++. When leaving the scope of a function, objects created in the stack are automatically deleted. This is the case for your TControlBar object. Instead of: TControlBar bar("vertical"); do TControlBar *bar = new TControlBar("vertical"); Unnamed macros execute in the global scope. Rene Brun Golovanov George wrote: > > Hi ROOTers, > > I want to call TControlBar from a function. When I try to call it from > a macros (i.e. code between { }): > > { > gROOT.Reset("a"); > TControlBar bar("vertical"); > bar.AddButton("Help",".x hsimple.C","About program"); > bar.AddButton("Exit",".q","Close Program"); > bar.Show(); > gROOT.SaveContext(); > } > > all work successfully. But when I try to call same code from > the function: > > void SimTest(){ > gROOT.Reset("a"); > TControlBar bar("vertical"); > bar.AddButton("Help",".x hsimple.C","About program"); > bar.AddButton("Exit",".q","Close Program"); > bar.Show(); > gROOT.SaveContext(); > } > > nothing appear on the screen. > Thanks for any help, > George.
This archive was generated by hypermail 2b29 : Thu Jan 01 2004 - 17:50:09 MET