Skip to content

Commit

Permalink
Reassociate entities in has many association when reset
Browse files Browse the repository at this point in the history
  • Loading branch information
danschultz committed Sep 8, 2011
1 parent c47bd96 commit f9ea5d4
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/mesh/model/associations/Association.as
Expand Up @@ -49,7 +49,7 @@ package mesh.model.associations
*/
protected function associate(entity:Entity):void
{
if (owner.store && entity.store == null) owner.store.add(entity);
if (owner.store != null && entity.store == null) owner.store.add(entity);
_entities.add(entity);
populateInverseRelationship(entity);
}
Expand Down
8 changes: 2 additions & 6 deletions src/mesh/model/associations/AssociationCollection.as
Expand Up @@ -80,15 +80,11 @@ package mesh.model.associations
private function handleEntitiesReset():void
{
for each (var oldEntity:Entity in _snapshot) {
if (_list.getItemIndex(oldEntity) == -1) {
handleEntitiesRemoved([oldEntity]);
}
handleEntitiesRemoved([oldEntity]);
}

for each (var newEntity:Entity in _list.toArray()) {
if (_snapshot.indexOf(newEntity) == -1) {
handleEntitiesAdded([newEntity]);
}
handleEntitiesAdded([newEntity]);
}
}

Expand Down

0 comments on commit f9ea5d4

Please sign in to comment.