From af6e2a430a6b04f1f0939a1965b85e5324a36a3c Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 6 Apr 2019 09:06:41 +0200 Subject: [PATCH] - fixed OnUnregister for Event handlers was called from a dead event manager instance. --- src/events.cpp | 13 ++++++------- src/events.h | 3 +-- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/events.cpp b/src/events.cpp index 69de8cca54..5b1edeec80 100755 --- a/src/events.cpp +++ b/src/events.cpp @@ -44,7 +44,6 @@ #include "utf8.h" EventManager staticEventManager; -EventManager eventManager; void EventManager::CallOnRegister() { @@ -262,7 +261,12 @@ void EventManager::InitStaticHandlers(FLevelLocals *l, bool map) void EventManager::Shutdown() { // delete handlers. + TArray list; for (DStaticEventHandler* handler = LastEventHandler; handler; handler = handler->prev) + { + list.Push(handler); + } + for (auto handler : list) { handler->Destroy(); } @@ -631,11 +635,6 @@ DEFINE_ACTION_FUNCTION(DStaticEventHandler, SetOrder) PARAM_SELF_PROLOGUE(DStaticEventHandler); 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; return 0; } @@ -1223,7 +1222,7 @@ void DStaticEventHandler::NewGame() // void DStaticEventHandler::OnDestroy() { - eventManager.UnregisterHandler(this); + owner->UnregisterHandler(this); Super::OnDestroy(); } diff --git a/src/events.h b/src/events.h index 7608dfa1ae..a2c5e67aa5 100755 --- a/src/events.h +++ b/src/events.h @@ -332,5 +332,4 @@ struct EventManager }; -extern EventManager eventManager; -extern EventManager staticEventManager; + extern EventManager staticEventManager;