Skip to content

Commit

Permalink
Fix crash with linked entities in the delayed deletion list
Browse files Browse the repository at this point in the history
Thanks to bsxf47 for tracking down the cause of the crash.

Fixes: issue #908
  • Loading branch information
dscharrer committed Oct 8, 2016
1 parent d075491 commit dee85f8
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/game/Entity.cpp
Expand Up @@ -279,6 +279,8 @@ res::path Entity::instancePath() const {

void Entity::cleanReferences() {

ARX_INTERACTIVE_DestroyIOdelayedRemove(this);

if(DRAGINTER == this) {
Set_DragInter(NULL);
}
Expand Down
6 changes: 6 additions & 0 deletions src/scene/Interactive.cpp
Expand Up @@ -2534,6 +2534,12 @@ void ARX_INTERACTIVE_DestroyIOdelayed(Entity * entity) {

}

void ARX_INTERACTIVE_DestroyIOdelayedRemove(Entity * entity) {
Entity * null = NULL;
// Remove the entity from the list but don't invalidate iterators
std::replace(toDestroy.begin(), toDestroy.end(), entity, null);
}

void ARX_INTERACTIVE_DestroyIOdelayedExecute() {
if(!toDestroy.empty()) {
LogDebug("executing delayed entity destruction");
Expand Down
1 change: 1 addition & 0 deletions src/scene/Interactive.h
Expand Up @@ -103,6 +103,7 @@ void PrepareIOTreatZone(long flag = 0);
void LinkObjToMe(Entity * io, Entity * io2, const std::string & attach);

void ARX_INTERACTIVE_DestroyIOdelayed(Entity * entity);
void ARX_INTERACTIVE_DestroyIOdelayedRemove(Entity * entity);
void ARX_INTERACTIVE_DestroyIOdelayedExecute();

/* TODO remove
Expand Down

0 comments on commit dee85f8

Please sign in to comment.