Re: problem with canvas

From: Rene Brun (Rene.Brun@cern.ch)
Date: Wed Sep 30 1998 - 09:03:16 MEST


T Auger wrote:
> 
> Hi Rooters,
> I have a problem with canvas when trying to use several times the
> same macro. Here is a sequence which shows the problems:
> 
> root [0] TCanvas c1("c1","Latex",600,700);
> (at this point I close the canvas with the mouse using the File menu)
> root [1] gROOT->Reset();
> 
>  *** Break *** segmentation violation
> 
> I do not have the problem if instead I do :
>      TCanvas *c1 = new TCanvas("c1","Latex",600,700);
> 
> Is there a bug?
> sincerely,
> Thierry.

This is a global scope problem with C++. You try to define
twice (or more) the same object.
The gROOT->Reset() statement is recommended at the beginning
of a Root macro to clear all CINT variables created in the global scope.
We recommend you to systematically use the "new XXX" form
to prevent this kind of problems. This is particularly true
for objects like TCanvas and TFile.

Rene Brun



This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:34:38 MET