Hi Sebastien
I tried your code and changed a few things :
//________________________________________
MyClassRef::~MyClassRef()
{
fRefArray.Clear();---> you don't really want to delete the objects you
reference, do you ?
}
void MyClassRef::Clear()
{
fRefArray.Clear();---> just clear out the list of references, but the
objects are deleted by the TClonesArray
}
//_________________________________________
void ReadTree()
{
.....
TClonesArray* clones = 0;
tree->SetBranchAddress("b_clones",&clones);
//connect the TRefArray branch as well - I have recently discovered that
if a branch contains objects
//which reference other objects in unconnected branches, the TTree can
create those objects all by
//itself (as well as recreating the TClonesArray without deleting the
old one) and cause monumental
//memory leaks...
MyClassRef* myclassref1 = 0;
tree->SetBranchAddress("b_myclassref1",&myclassref1);
//_______________________________________________
but I still see the same result as you -
twice as many objects in the final myclassref2 and I don't know why. As
for the
result being different when you read or write, if you mean the unique
identifiers
are not the same, I don't think it's important as they are just internal
counters
for ROOT (aren't they ???).
Sorry
John
> The final output has changed.
>
> Well, this is due to the fact that it is a new ROOT
> session.
>
> But what I'd like to understand is why the objects
> in myclassref2's TRefArray have been doubled ?
>
>
>
--
John D. Frankland <mailto:frankland@ganil.fr>
Beam Coordinator
GANIL
B.P. 55027
14076 CAEN Cedex 05
*tel:* +33 (0)231454628
*fax:* +33 (0)231454665
This archive was generated by hypermail 2b29 : Thu Jan 01 2004 - 17:50:16 MET