Bugfix for setting nil values to scalar types.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/branches/freeze-1_6_0@16044 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-Macdonald 2003-02-22 05:35:58 +00:00
parent c273a0f128
commit 396a0ce508
2 changed files with 18 additions and 2 deletions

View file

@ -1,3 +1,8 @@
2003-02-22 Richard Frith-Macdonald <rfm@gnu.org>
* Source/Additions/GSObjCRuntime.m: GSObjCSetValue() correct to call
([unableToSetNilForKey:]) when it should.
2003-02-21 Richard Frith-Macdonald <rfm@gnu.org>
* Source/NSDistributedNotificationCenter.m: ([_connect]) make the

View file

@ -45,6 +45,8 @@
#include <gnustep/base/GSObjCRuntime.h>
#include <string.h>
@class NSNull;
/** Deprecated ... use GSObjCFindVariable() */
BOOL
GSFindInstanceVariable(id obj, const char *name,
@ -981,6 +983,12 @@ void
GSObjCSetValue(NSObject *self, NSString *key, id val, SEL sel,
const char *type, unsigned size, int offset)
{
static NSNull *null = nil;
if (null == nil)
{
null = [NSNull new];
}
if (sel != 0)
{
NSMethodSignature *sig = [self methodSignatureForSelector: sel];
@ -996,6 +1004,10 @@ GSObjCSetValue(NSObject *self, NSString *key, id val, SEL sel,
{
[self handleTakeValue: val forUnboundKey: key];
}
else if ((val == nil || val == null) && *type != _C_ID && *type != _C_CLASS)
{
[self unableToSetNilForKey: key];
}
else
{
switch (*type)
@ -1009,8 +1021,7 @@ GSObjCSetValue(NSObject *self, NSString *key, id val, SEL sel,
{
id *ptr = (id *)((char *)self + offset);
[*ptr autorelease];
*ptr = [v retain];
ASSIGN(*ptr, v);
}
else
{