TBrowser, TApplication, g++

I have the following small application:
int main()
TApplication app(“myapp”, 0, 0);
TFile * test_file = new
TFile("/home/address/test_file.root", “recreate”);
TH2F *h1 = new TH2F(“h1”, “h1”, 6, 0, 3, 6, 0, 3);
gROOT -> SetBatch(kTRUE);
test_file -> cd();
TStyle *style = new TStyle(“style”, “style”);
style -> SetPalette(1);
TCanvas *c = new TCanvas(“c”, “c”);
h1 -> Draw(“COLZ”);

c -> Write();
gROOT -> SetBatch(kFALSE);

TBrowser *browser = new TBrowser();

However, when I click on TCanvas c in TBrowser, an error message posted below appears. If the lines gROOT -> SetBatch(kTRUE) and gROOT ->SetBatch(kFALSE) are commented I no longer receive the error message. However, my intention is that the TCanvas opens only if clicked inside TBrowser, therefore I want to keep the batch mode.
I compile the code with g++.
How can I improve my application so that I don’t receive the error message?
Thank you,

Warning in TFile::Init: file test_file.root probably not closed, trying to recover
Info in TFile::Recover: test_file.root, recovered key TCanvas:c at address 326
Warning in TFile::Init: successfully recovered 1 keys

*** Break *** segmentation violation
Attaching to program: /proc/21956/exe, process 21956
[Thread debugging using libthread_db enabled]

warning: no loadable sections found in added symbol-file system-supplied DSO at 0x7fff5c9fd000
0x0000003058099df5 in waitpid () from /lib64/libc.so.6
#1 0x000000305803c7a1 in do_system () from /lib64/libc.so.6
#2 0x00002b046111b45c in TUnixSystem::StackTrace() ()
from /usr/local/lib/root/libCore.so
#3 0x00002b046111a603 in TUnixSystem::DispatchSignals(ESignals) ()
from /usr/local/lib/root/libCore.so
#5 0x00002b046537df3b in TGX11::CloseWindow1() ()
from /usr/local/stow/root/lib/root/libGX11.so
#6 0x00002b04635ccb5d in TPad::Close(char const*) ()
from /usr/local/lib/root/libGpad.so
#7 0x00002b04635b1e01 in TCanvas::Close(char const*) ()
from /usr/local/lib/root/libGpad.so
#8 0x00002b04635b1454 in TCanvas::Destructor() ()
from /usr/local/lib/root/libGpad.so
#9 0x00002b04635b14a7 in TCanvas::~TCanvas() ()
from /usr/local/lib/root/libGpad.so
#10 0x00002b04635b29f4 in TCanvas::Draw(char const*) ()
from /usr/local/lib/root/libGpad.so
#11 0x00002b04635b0271 in TCanvas::Browse(TBrowser*) ()
from /usr/local/lib/root/libGpad.so
#12 0x00002b04610f6074 in TClass::Browse(void*, TBrowser*) const ()
from /usr/local/lib/root/libCore.so
#13 0x00002b0462259fc5 in TKey::Browse(TBrowser*) ()
from /usr/local/lib/root/libRIO.so
#14 0x00002b046585c6af in TRootBrowserLite::IconBoxAction(TObject*) ()
from /usr/local/stow/root/lib/root/libGui.so
#15 0x00002b046585d0e6 in TRootBrowserLite::ProcessMessage(long, long, long) ()
from /usr/local/stow/root/lib/root/libGui.so
#16 0x00002b04657b6339 in TGFrame::HandleClientMessage(Event_t*) ()
from /usr/local/stow/root/lib/root/libGui.so
#17 0x00002b04657b8d49 in TGMainFrame::HandleClientMessage(Event_t*) ()
from /usr/local/stow/root/lib/root/libGui.so
#18 0x00002b04657b916f in TGFrame::HandleEvent(Event_t*) ()
from /usr/local/stow/root/lib/root/libGui.so
#19 0x00002b046578722c in TGClient::HandleEvent(Event_t*) ()
from /usr/local/stow/root/lib/root/libGui.so
#20 0x00002b04657875f1 in TGClient::ProcessOneEvent() ()
from /usr/local/stow/root/lib/root/libGui.so
#21 0x00002b046578766d in TGClient::HandleInput() ()
from /usr/local/stow/root/lib/root/libGui.so
#22 0x00002b046578768d in TGInputHandler::Notify() ()
from /usr/local/stow/root/lib/root/libGui.so
#23 0x00002b046111ac28 in TUnixSystem::DispatchOneEvent(bool) ()
from /usr/local/lib/root/libCore.so
#24 0x00002b04610b3546 in TSystem::InnerLoop() ()
from /usr/local/lib/root/libCore.so
#25 0x00002b04610b445c in TSystem::Run() () from /usr/local/lib/root/libCore.so
#26 0x00002b046106338f in TApplication::Run(bool) ()
from /usr/local/lib/root/libCore.so
#27 0x0000000000402024 in main ()
A debugging session is active.

Inferior 1 [process 21956] will be detached.

Quit anyway? (y or n) [answered Y; input not from terminal]
Detaching from program: /proc/21956/exe, process 21956


I cannot reproduce the problem (or I don’t understand what you explained…)
And the usual questions: Which version of ROOT? Which OS? Which compiler?
And could you describe precisely what you did to get this crash (exact list and order of actions)?

Cheers, Bertrand,

I use ROOT 5.17/06 (trunk@21138, Feb 08 2011, 16:48:00 on linuxx8664gcc)
CINT/ROOT C/C++ Interpreter version 5.16.27, Oct 25, 2007

I work in Linux 2.6.18-348.el5.centos.plus

I compile my code with g++

When the TBrowser opens I click on file test_file.root, then I click on TCanvas c. When cliking on c I get the error message.

OK, thanks. This is a quite old version of ROOT (2007)… Could you try with a more recent version?

Cheers, Bertrand.