X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=lib%2Fspecial%2Fgame_object.cpp;h=7a9db2b4fd302db74730e46c57ce3bb64595ca50;hb=8e0bad9f82ccbc811a18edd7ce6c6f69c5bca082;hp=c3fd98dcd1eb5e4ace9d673a85bc0b80752a2624;hpb=e4d4375bf4b6802321d956f5f3886320b7275cf0;p=supertux.git diff --git a/lib/special/game_object.cpp b/lib/special/game_object.cpp index c3fd98dcd..7a9db2b4f 100644 --- a/lib/special/game_object.cpp +++ b/lib/special/game_object.cpp @@ -19,18 +19,27 @@ #include -#include "special/game_object.h" +#include "game_object.h" +#include "object_remove_listener.h" namespace SuperTux { GameObject::GameObject() - : wants_to_die(false), flags(0) + : wants_to_die(false), remove_listeners(0), flags(0) { } GameObject::~GameObject() { + // call remove listeners (and remove them from the list) + RemoveListenerListEntry* entry = remove_listeners; + while(entry != 0) { + RemoveListenerListEntry* next = entry->next; + entry->listener->object_removed(this); + delete entry; + entry = next; + } } }