[ROOT] TBranchClones and TClonesArray::RemoveAt

From: Manuel Sánchez García (M.Sanchez@gsi.de)
Date: Fri Jul 05 2002 - 17:20:44 MEST


Hi,

Could anybody tell me what's wrong with the following reasoning?

Let's say we have TClonesArray in a TTree. In my eventLoop I call
RemoveAt and then Compress(). Now, RemoveAt() doesn't free the memory in
fKeep->fCont[i] but calls the destructor; now the virtual table pointer
points to that of one TObject.  (This can be checked directly on the
interpreter)

Now, next event comes. In the TBranchClones::GetEntry a
ExpandCreateFast() is done; this expands the TClonesArray and prepares
it to dump the data from the branch. Now for each element 'i' in the
array 2 things may happen

1.- fCont[i]==0  && fKeep->fCont[i]==0   => the object is created and
the default constructor called. This is fine

2.- fCont[i]==0 && fKeep->fCont[i]!=0   -> The constructor is not
called; but if the object's destructor was called in advance the virtual
table is not correct.

This problem doesn't show up when only TClonesArray::Clear() is done
because that doesn't involve calling destructors.

Is this a bug or am I missing something?

Best regards,
	Manuel



This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:50:59 MET