mirror of
https://github.com/gnustep/libs-gdl2.git
synced 2025-02-19 17:50:47 +00:00
* EOControl/EOGenericRecord.m: fix -willChange call (don't call
it for takeStoredValue:forKey and for -setXX method). * EOControl/EOClassDescription.m: check if value is not already set before adding/setting it in _setObject:forBothSidesOfRelationshipWithKey: and addObject:toBothSidesOfRelationshipWithKey: * EOAccess/EOAttribute.m: log in -validateValue: git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gdl2/trunk@21669 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
41b2d38380
commit
d6d1029a3e
4 changed files with 88 additions and 62 deletions
10
ChangeLog
10
ChangeLog
|
@ -1,3 +1,13 @@
|
|||
2005-08-23 Manuel Guesdon <mguesdon@orange-concept.com>
|
||||
|
||||
* EOControl/EOGenericRecord.m: fix -willChange call (don't call
|
||||
it for takeStoredValue:forKey and for -setXX method).
|
||||
* EOControl/EOClassDescription.m: check if value is not
|
||||
already set before adding/setting it in
|
||||
_setObject:forBothSidesOfRelationshipWithKey: and
|
||||
addObject:toBothSidesOfRelationshipWithKey:
|
||||
* EOAccess/EOAttribute.m: log in -validateValue:
|
||||
|
||||
2005-08-17 David Ayers <d.ayers@inode.at>
|
||||
|
||||
* COPYING.LIB: Update to LGPL 2.1.
|
||||
|
|
|
@ -1596,6 +1596,8 @@ More details:
|
|||
{
|
||||
NSException *exception=nil;
|
||||
|
||||
EOFLOGObjectFnStart();
|
||||
|
||||
NSAssert(valueP, @"No value pointer");
|
||||
|
||||
NSDebugMLog(@"In EOAttribute validateValue: value (class=%@) = %@ attribute = %@",
|
||||
|
@ -1797,6 +1799,8 @@ More details:
|
|||
}
|
||||
}
|
||||
|
||||
EOFLOGObjectFnStop();
|
||||
|
||||
return exception;
|
||||
}
|
||||
|
||||
|
|
|
@ -1211,7 +1211,7 @@ fromInsertionInEditingContext: (EOEditingContext *)anEditingContext
|
|||
NSDebugMLLog(@"gsdb",
|
||||
@"TOMANY snap=%p key=%@ ==> value %p=%@",
|
||||
snapshot, key, value, value);
|
||||
|
||||
|
||||
value = AUTORELEASE([(NSArray *)value shallowCopy]);
|
||||
NSDebugMLLog(@"gsdb",
|
||||
@"TOMANY snap=%p key=%@ ==> value %p=%@",
|
||||
|
@ -1475,6 +1475,10 @@ toPropertyWithKey: (NSString *)key
|
|||
}
|
||||
else
|
||||
{
|
||||
NSDebugMLLog(@"gsdb",
|
||||
@"Object %p not already in too many val=%@ (%@)",
|
||||
object, val, [val class]);
|
||||
|
||||
if ([val isKindOfClass: GDL2_NSMutableArrayClass])
|
||||
{
|
||||
EOFLOGObjectLevel(@"gsdb", @"to many2");
|
||||
|
@ -1619,10 +1623,9 @@ toPropertyWithKey: (NSString *)key
|
|||
forBothSidesOfRelationshipWithKey: (NSString*)key
|
||||
{
|
||||
//Near OK
|
||||
NSString *inverseKey;
|
||||
id oldObject;
|
||||
|
||||
EOFLOGObjectFnStart();
|
||||
|
||||
NSDebugMLLog(@"gsdb", @"self=%@", self);
|
||||
NSDebugMLLog(@"gsdb", @"object=%@", object);
|
||||
NSDebugMLLog(@"gsdb", @"key=%@", key);
|
||||
|
@ -1633,51 +1636,33 @@ forBothSidesOfRelationshipWithKey: (NSString*)key
|
|||
}
|
||||
else
|
||||
{
|
||||
inverseKey = [self inverseForRelationshipKey:key];
|
||||
NSDebugMLLog(@"gsdb", @"inverseKey=%@", inverseKey);
|
||||
|
||||
oldObject = [self valueForKey: key];
|
||||
id oldObject = [self valueForKey: key];
|
||||
NSDebugMLLog(@"gsdb", @"oldObject=%@", oldObject);
|
||||
|
||||
if (inverseKey)
|
||||
if (object!=oldObject) // Don't put it again if it is already set
|
||||
{
|
||||
if (oldObject==GDL2_EONull)
|
||||
{
|
||||
NSWarnMLog(@"Warning: oldObject is an EONull. self=%@ key=%@ object=%@",self,key,object);
|
||||
}
|
||||
else
|
||||
{
|
||||
[oldObject removeObject: self
|
||||
fromPropertyWithKey: inverseKey];
|
||||
[object addObject: self
|
||||
toPropertyWithKey: inverseKey];
|
||||
/* if ([object isToManyKey:inverseKey])
|
||||
{
|
||||
//??
|
||||
EOFLOGObjectLevel(@"gsdb",@"Inverse is to many");
|
||||
[oldObject removeObject:self
|
||||
fromPropertyWithKey:inverseKey];
|
||||
[object addObject:self
|
||||
toPropertyWithKey:inverseKey];
|
||||
}
|
||||
else
|
||||
{
|
||||
EOFLOGObjectLevel(@"gsdb",@"Inverse is not to many");
|
||||
//OK
|
||||
//MIRKO if ((inverseKey = [oldObject inverseForRelationshipKey:key]))
|
||||
//MIRKO [oldObject removeObject:self
|
||||
// fromPropertyWithKey:inverseKey];
|
||||
[oldObject takeValue:nil
|
||||
forKey:inverseKey];
|
||||
[object takeValue:self
|
||||
forKey:inverseKey];
|
||||
};
|
||||
*/
|
||||
}
|
||||
}
|
||||
NSString *inverseKey = NULL;
|
||||
inverseKey = [self inverseForRelationshipKey:key];
|
||||
NSDebugMLLog(@"gsdb", @"inverseKey=%@", inverseKey);
|
||||
|
||||
[self takeValue: object
|
||||
forKey: key];
|
||||
if (inverseKey)
|
||||
{
|
||||
if (oldObject==GDL2_EONull)
|
||||
{
|
||||
NSWarnMLog(@"Warning: oldObject is an EONull. self=%@ key=%@ object=%@",self,key,object);
|
||||
}
|
||||
else
|
||||
{
|
||||
[oldObject removeObject: self
|
||||
fromPropertyWithKey: inverseKey];
|
||||
[object addObject: self
|
||||
toPropertyWithKey: inverseKey];
|
||||
}
|
||||
}
|
||||
|
||||
[self takeValue: object
|
||||
forKey: key];
|
||||
}
|
||||
}
|
||||
|
||||
NSDebugMLLog(@"gsdb", @"self=%@", self);
|
||||
|
@ -1741,16 +1726,20 @@ toBothSidesOfRelationshipWithKey: (NSString *)key
|
|||
|
||||
NSDebugMLLog(@"gsdb", @"oldObject=%@", oldObject);
|
||||
|
||||
if (oldObject)
|
||||
// Don't put it again if it already set
|
||||
if (object!=oldObject)
|
||||
{
|
||||
//TODO VERIFY
|
||||
[object removeObject:oldObject
|
||||
fromPropertyWithKey:inverseKey];
|
||||
}
|
||||
|
||||
// Just set self into object relationship property
|
||||
[object takeValue: self
|
||||
forKey: inverseKey];
|
||||
if (oldObject)
|
||||
{
|
||||
//TODO VERIFY
|
||||
[object removeObject:oldObject
|
||||
fromPropertyWithKey:inverseKey];
|
||||
}
|
||||
|
||||
// Just set self into object relationship property
|
||||
[object takeValue: self
|
||||
forKey: inverseKey];
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -307,8 +307,6 @@ static const char _c_id[2] = { _C_ID, 0 };
|
|||
@"Super InstanceVar named %@: offset=%u",
|
||||
aKey, offset);
|
||||
|
||||
[self willChange];
|
||||
|
||||
if (offset == UINT_MAX)
|
||||
{
|
||||
if (anObject)
|
||||
|
@ -724,8 +722,12 @@ inline BOOL infoForInstanceVariableWithImpPtr(id object,GDL2IMP_BOOL* impPtr,
|
|||
- (void)smartTakeValue: (id)anObject
|
||||
forKey: (NSString *)aKey
|
||||
{
|
||||
BOOL isToMany = [[classDescription toManyRelationshipKeys]
|
||||
containsObject: aKey];
|
||||
BOOL isToMany = NO;
|
||||
|
||||
EOFLOGObjectFnStartCond(@"EOGenericRecordKVC");
|
||||
|
||||
isToMany=[[classDescription toManyRelationshipKeys]
|
||||
containsObject: aKey];
|
||||
|
||||
//NSDebugMLog(@"aKey=%@ rel=%@ anObject=%@", aKey, rel, anObject);
|
||||
//NSDebugMLog(@"[rel isBidirectional]=%d", [rel isBidirectional]);
|
||||
|
@ -755,6 +757,8 @@ inline BOOL infoForInstanceVariableWithImpPtr(id object,GDL2IMP_BOOL* impPtr,
|
|||
else
|
||||
[self takeValue: anObject
|
||||
forKey: aKey];
|
||||
|
||||
EOFLOGObjectFnStopCond(@"EOGenericRecordKVC");
|
||||
}
|
||||
|
||||
//MG#if !FOUNDATION_HAS_KVC
|
||||
|
@ -783,6 +787,10 @@ inline BOOL infoForInstanceVariableWithImpPtr(id object,GDL2IMP_BOOL* impPtr,
|
|||
GDL2IMP_BOOL rtsIMP=NULL;
|
||||
GDL2IMP_BOOL infoVarIMP=NULL;
|
||||
|
||||
// We'll call willChange if we modify ivar directly or call a _setMethod
|
||||
// otherwise, the setMethod should do it
|
||||
BOOL shouldCallWillChange=NO; //OXYMIUM
|
||||
|
||||
strcpy(buf, "_set");
|
||||
[aKey getCString: &buf[4]];
|
||||
lo = buf[4];
|
||||
|
@ -807,8 +815,12 @@ inline BOOL infoForInstanceVariableWithImpPtr(id object,GDL2IMP_BOOL* impPtr,
|
|||
aKey, buf);
|
||||
sel = GSSelectorFromName(buf);
|
||||
|
||||
if (sel == 0 ||
|
||||
GDL2_RespondsToSelectorWithImpPtr(self,&rtsIMP,sel) == NO)
|
||||
if (sel != 0 &&
|
||||
GDL2_RespondsToSelectorWithImpPtr(self,&rtsIMP,sel) == YES)
|
||||
{
|
||||
shouldCallWillChange=YES;
|
||||
}
|
||||
else
|
||||
{
|
||||
sel = 0;
|
||||
|
||||
|
@ -832,7 +844,12 @@ inline BOOL infoForInstanceVariableWithImpPtr(id object,GDL2IMP_BOOL* impPtr,
|
|||
nil, // stringName
|
||||
&type, // retType
|
||||
&size, // retSize
|
||||
&off)==NO) // retOffset
|
||||
&off)==YES) // retOffset
|
||||
{
|
||||
// We'll call willChange
|
||||
shouldCallWillChange=YES;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Test key
|
||||
EOFLOGObjectLevelArgs(@"EOGenericRecordKVC",
|
||||
|
@ -849,14 +866,20 @@ inline BOOL infoForInstanceVariableWithImpPtr(id object,GDL2IMP_BOOL* impPtr,
|
|||
&type, // retType
|
||||
&size, // retSize
|
||||
&off); // retOffset
|
||||
// We'll call willChange
|
||||
shouldCallWillChange=YES;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
EOFLOGObjectLevelArgs(@"EOGenericRecordKVC",
|
||||
@"aKey=%@ sel=%@ offset=%u",
|
||||
aKey, NSStringFromSelector(sel), off);
|
||||
@"aKey=%@ sel=%@ offset=%u shouldCallWillChange=%d",
|
||||
aKey, NSStringFromSelector(sel), off,
|
||||
shouldCallWillChange);
|
||||
|
||||
if (shouldCallWillChange)
|
||||
[self willChange];
|
||||
|
||||
[self _setValueForKey: aKey
|
||||
object: anObject
|
||||
|
|
Loading…
Reference in a new issue