mirror of
https://github.com/gnustep/libs-gdl2.git
synced 2025-04-25 13:50:54 +00:00
* EOAccess/EORelationship.m ([-setEntity:]): Modify remove
relatioship from previous entity and add recursion detection. Add documention. * EOAccess/EOEntity.m ([-removeRelationship:]): Move call to [EORelationship-setEntity:] to allow recursion detection. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gdl2/trunk@26222 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
9eed6a685e
commit
be3346e4ad
3 changed files with 39 additions and 9 deletions
|
@ -1,3 +1,11 @@
|
|||
2008-03-06 David Ayers <ayers@fsfe.org>
|
||||
|
||||
* EOAccess/EORelationship.m ([-setEntity:]): Modify remove
|
||||
relatioship from previous entity and add recursion detection.
|
||||
Add documention.
|
||||
* EOAccess/EOEntity.m ([-removeRelationship:]): Move call
|
||||
to [EORelationship-setEntity:] to allow recursion detection.
|
||||
|
||||
2008-03-05 David Ayers <ayers@fsfe.org>
|
||||
|
||||
* EOControl/EOKeyGlobalID.m ([+assignGloballyUniqueBytes:]):
|
||||
|
|
|
@ -1908,13 +1908,9 @@ createInstanceWithEditingContext:globalID:zone:
|
|||
*/
|
||||
- (void)removeRelationship: (EORelationship *)relationship
|
||||
{
|
||||
NSEmitTODO(); //TODO
|
||||
|
||||
//TODO
|
||||
if (relationship)
|
||||
{
|
||||
[self willChange];
|
||||
[relationship setEntity:nil];
|
||||
|
||||
if(_relationshipsByName != nil)
|
||||
[_relationshipsByName removeObjectForKey:[relationship name]];
|
||||
|
@ -1940,6 +1936,10 @@ createInstanceWithEditingContext:globalID:zone:
|
|||
initWithArray:AUTORELEASE(_classProperties)
|
||||
copyItems:NO];
|
||||
}
|
||||
/* We call this after adjusting the arrays so that setEntity: has
|
||||
the opportunity to check the relationships before calling
|
||||
removeRelationshipt which would lead to an infinite loop. */
|
||||
[relationship setEntity:nil];
|
||||
[self _setIsEdited];//To clean caches
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1302,6 +1302,15 @@ relationships. Nil if none" **/
|
|||
EOFLOGObjectFnStop();
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Sets the entity of the reciever.</p>
|
||||
* <p>If the receiver already has an entity assigned to it the old relationship
|
||||
* will will be removed first.</p>
|
||||
* <p>This method is used by [EOEntity-addRelationship:] and
|
||||
* [EOEntity-removeRelationship:] which should be used for general relationship
|
||||
* manipulations. This method should only be useful
|
||||
* when creating flattend relationships programmatically.</p>
|
||||
*/
|
||||
- (void)setEntity: (EOEntity *)entity
|
||||
{
|
||||
//OK
|
||||
|
@ -1309,13 +1318,26 @@ relationships. Nil if none" **/
|
|||
{
|
||||
[self _flushCache];
|
||||
[self willChange];
|
||||
/* FIXME docs say we should... but currently -removeRelationship
|
||||
* calls us, so it would cause an infinite loop */
|
||||
// [_entity removeRelationship:self];
|
||||
[_entity _setIsEdited];
|
||||
[entity _setIsEdited];
|
||||
|
||||
if (_entity)
|
||||
{
|
||||
NSString *relationshipName;
|
||||
EORelationship *relationship;
|
||||
|
||||
/* Check if we are still in the entities arrays to
|
||||
avoid recursive loop when removeRelationship:
|
||||
calls this method. */
|
||||
relationshipName = [self name];
|
||||
relationship = [_entity relationshipNamed: relationshipName];
|
||||
if (self == relationship)
|
||||
{
|
||||
[_entity removeRelationship: self];
|
||||
}
|
||||
}
|
||||
_entity = entity;
|
||||
}
|
||||
/* This method is used by EOEntity's remove/addRelatinship: and is not
|
||||
responsible for calling _setIsEdited on the entity. */
|
||||
}
|
||||
|
||||
- (void)setUserInfo: (NSDictionary *)dictionary
|
||||
|
|
Loading…
Reference in a new issue