- fixed OnUnregister for Event handlers was called from a dead event manager instance.

This commit is contained in:
Christoph Oelckers 2019-04-06 09:06:41 +02:00
parent c65ecbc807
commit af6e2a430a
2 changed files with 7 additions and 9 deletions

View file

@ -44,7 +44,6 @@
#include "utf8.h" #include "utf8.h"
EventManager staticEventManager; EventManager staticEventManager;
EventManager eventManager;
void EventManager::CallOnRegister() void EventManager::CallOnRegister()
{ {
@ -262,7 +261,12 @@ void EventManager::InitStaticHandlers(FLevelLocals *l, bool map)
void EventManager::Shutdown() void EventManager::Shutdown()
{ {
// delete handlers. // delete handlers.
TArray<DStaticEventHandler *> list;
for (DStaticEventHandler* handler = LastEventHandler; handler; handler = handler->prev) for (DStaticEventHandler* handler = LastEventHandler; handler; handler = handler->prev)
{
list.Push(handler);
}
for (auto handler : list)
{ {
handler->Destroy(); handler->Destroy();
} }
@ -631,11 +635,6 @@ DEFINE_ACTION_FUNCTION(DStaticEventHandler, SetOrder)
PARAM_SELF_PROLOGUE(DStaticEventHandler); PARAM_SELF_PROLOGUE(DStaticEventHandler);
PARAM_INT(order); PARAM_INT(order);
/* not really needed - this is never checked again. To re-add, the handlers need a pointer to their manager but that's not worth it just for this check.
if (eventManager.CheckHandler(self))
return 0;
*/
self->Order = order; self->Order = order;
return 0; return 0;
} }
@ -1223,7 +1222,7 @@ void DStaticEventHandler::NewGame()
// //
void DStaticEventHandler::OnDestroy() void DStaticEventHandler::OnDestroy()
{ {
eventManager.UnregisterHandler(this); owner->UnregisterHandler(this);
Super::OnDestroy(); Super::OnDestroy();
} }

View file

@ -332,5 +332,4 @@ struct EventManager
}; };
extern EventManager eventManager; extern EventManager staticEventManager;
extern EventManager staticEventManager;