[Hessianobjc-user] Bug decoding references to mapped class instances
Status: Alpha
Brought to you by:
cocoa_dood
|
From: Tom D. <tgd...@gm...> - 2007-12-15 01:22:30
|
When a map is decoded, the NSDictionary is stored in the refArray,
even if the dictionary is subsequently mapped to a class. This means
that references get the dictionary, not the class:
Here's a simple fix which defers storing the reference until the end:
- (id) decodeMap {
id dict = [NSMutableDictionary dictionary];
- //add the pointer to the ref array and not the actually value.
- [refArray addObject:[NSValue valueWithPointer:dict]];
Class mappedClass = nil;
uint8_t objectTag = 'e';
if([dataInputStream hasBytesAvailable]) {
@@ -264,9 +297,11 @@
if(mappedClass) {
//a mapped class, user map decoder to init object
BBSHessianMapDecoder * mapDecoder =
[[[BBSHessianMapDecoder alloc] initForReadingWithDictionary:dict]
autorelease];
- id obj = [[[mappedClass alloc] initWithCoder:mapDecoder]
autorelease];
+ id obj = [[[mappedClass alloc] initWithCoder:mapDecoder]
autorelease];
+ [refArray addObject:[NSValue valueWithPointer:obj]];
return obj;
}
+ [refArray addObject:[NSValue valueWithPointer:dict]];
return dict;
}
else {
|