zero reference when object is collected

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@27704 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-MacDonald 2009-01-27 14:06:20 +00:00
parent 1613ab58b5
commit 96748dc007
3 changed files with 20 additions and 2 deletions

View file

@ -1,3 +1,8 @@
2009-01-27 Richard Frith-Macdonald <rfm@gnu.org>
* Source/NSValue.m: ([valueWithNonretainedObject:]) zero the reference
when the object is collected.
2009-01-25 Richard Frith-Macdonald <rfm@gnu.org>
* Source/NSURL.m: Compatibility tweaks for a few MacOS-X oddities...

View file

@ -90,8 +90,18 @@
* Ensure that the version encoded is that used by the abstract class.
*/
[self setVersion: [super version]];
#if TYPE_ORDER == 0 && GS_WITH_GC
GSMakeWeakPointer(self, "data");
#endif
}
#if TYPE_ORDER == 0 && GS_WITH_GC
- (void) finalize
{
GSAssignZeroingWeakPointer((void**)&data, (void*)nil);
}
#endif
// Allocating and Initializing
- (id) initWithBytes: (const void *)value
@ -99,7 +109,11 @@
{
typedef __typeof__(data) _dt;
self = [super init];
#if TYPE_ORDER == 0 && GS_WITH_GC
GSAssignZeroingWeakPointer((void**)&data, (void*)(*(id*)value));
#else
data = *(_dt *)value;
#endif
return self;
}

View file

@ -756,8 +756,7 @@ static Class NSDataMallocClass;
*/
if (c == nil)
{
NSLog(@"Got nil when trying to unarchive class %s",
className);
NSLog(@"Unable to find class named '%s'", className);
}
[classInfo mapToClass: c withName: className];
[objDict setObject: classInfo forKey: className];