Destruction of objects when exiting root

Hi everyone. I have a class with some file.Write() in its destructor and found that if interactively I create an object and quit root, it would complain that the file is not writable. A search lead me to this post:

a.C (520 Bytes)

I run the attachment (I added #include and using statements to make ROOT take it) in ROOT 6.10/00:

$ root

| Welcome to ROOT 6.10/00 http://root.cern.ch |
| (c) 1995-2017, The ROOT Team |
| Built for linuxx8664gcc |
| From tag v6-10-00, 13 June 2017 |

Try ‘.help’, ‘.demo’, ‘.license’, ‘.credits’, ‘.quit’/‘.q’

root [0] .L a.C+
Info in TUnixSystem::ACLiC: creating shared library /home/pliu/sandbox/dtor/./a_C.so
root [1] a obj
a ctor
f1 Writable = 1
(a &) @0x(some memory address)
root [2] .q
a dtor
f1 Writable = 0
Warning in TFile::Write: file a.root not opened in write mode
$
And there is no histogram in a.root. pcanal said “This problem will be resolved in the context of ROOT 6 (and the replacement of CINT by Cling)”. I wonder if this is actually the case?

Hi,

thanks for reporting. This is a tear-down issue. I see some workaround possible, for example you could explicitly allow flushing of the content of your object with a method, perhaps also invoked in the destructor for automatic flushing when the class is not used at the prompt.

Cheers,
D

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.