Re: Error in <TExMap::Add>: key 2 is not unique

From: Rene Brun <>
Date: Fri, 18 Mar 2005 21:45:32 +0100 (MET)

Hi Egon,

Why do you try to do this yourself? Let the system do the I/O of your class automatically in the default generated Streamer. It looks like you forgot to Call the TBuffer::Initmap function. I suggest to look into the code of TBuffer::WriteObject. But, I repeat, this is the wrong approach. Use the automatic Streamer. If you still have problems, you will have to send the shortest possible concrete example that we can execute.

Rene Brun

Fri, 18
Mar 2005, Egon Pavlica wrote:

> Hello rooters!
> Does anybody know this problem (i think is a problem). I have a class,
> child of a TObject, which has own Streamer. In this streamer i stream two
> members - classes, also children of TObject. These two members are
> pointers of type ClassA but actually they are any of classes ClassB
> or ClassC, that are children of ClassA, i use this procedure to stream:
> R__b.WriteClass(classA1->Class());
> R__b.WriteObjectAny(classA1,classA1->Class());
> R__b.WriteClass(classA2->Class());
> R__b.WriteObjectAny(classA2,classA2->Class());
> and
> TClass* cl=R__b.ReadClass();
> classA1=(classA1*)R__b.ReadObjectAny(cl);
> //delete cl;
> TClass* cl2=R__b.ReadClass();
> classA2=(classA2*)R__b.ReadObjectAny(cl2);
> //delete cl2;
> this reading gives the error:
> Error in <TExMap::Add>: key 2 is not unique
> that really confuse me. i cant afford any memory leak. so i am wondering
> why cant i delete classes cl and cl2. Also, it there any other posibility
> to stream classes classB and classC, which addresses are stored in classA1
> and classA2.
> thanks,
> Egon Pavlica
Received on Fri Mar 18 2005 - 21:45:36 MET

This archive was generated by hypermail 2.2.0 : Tue Jan 02 2007 - 14:45:06 MET