Skip to content

Commit

Permalink
Make sure offspring organisms are deleted if DoBirth fails.
Browse files Browse the repository at this point in the history
  • Loading branch information
mercere99 committed Apr 6, 2018
1 parent 6e6a4af commit 7a29b2c
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion source/Evolve/World.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
* facilitate demes, pools, islands, etc.
* @todo We should be able to have any number of systematics managers, based on various type_trait
* information a that we want to track.
* @todo Add a signal for DoBirth() for when a birth fails.
*/

#ifndef EMP_EVO_WORLD_H
Expand Down Expand Up @@ -1024,7 +1025,13 @@ namespace emp {
Ptr<ORG> new_org = NewPtr<ORG>(mem);
offspring_ready_sig.Trigger(*new_org);
const OrgPosition pos = fun_add_birth(new_org, parent_pos);
if (pos.IsActive()) org_placement_sig.Trigger(pos.GetIndex());
if (pos.IsActive()) {
// If organism was placed right into the active population, trigger placement signal.
org_placement_sig.Trigger(pos.GetIndex());
} else if (!pos.IsValid()) {
// Organism failed to be placed in the population. Delete it.
new_org.Delete();
}
// SetupOrg(*new_org, &callbacks, pos);
return pos;
}
Expand Down

0 comments on commit 7a29b2c

Please sign in to comment.