Fix crashes after detaching with uncleared event callbacks
This commit is contained in:
parent
a60f52fa9d
commit
9ca31329f9
@ -10,6 +10,7 @@ namespace gui
|
||||
{
|
||||
|
||||
void init();
|
||||
void shutdown();
|
||||
void draw();
|
||||
bool handleSdlEvent(SDL_Event *event);
|
||||
|
||||
|
@ -17,6 +17,7 @@
|
||||
#include "hack.hpp"
|
||||
#include "common.hpp"
|
||||
#include "MiscTemporary.hpp"
|
||||
#include "menu/GuiInterface.hpp"
|
||||
#include <link.h>
|
||||
#include <pwd.h>
|
||||
|
||||
@ -400,6 +401,10 @@ void hack::Shutdown()
|
||||
delete g_pLocalPlayer;
|
||||
delete g_pTeamRoundTimer;
|
||||
delete g_pPlayerResource;
|
||||
#if ENABLE_GUI
|
||||
logging::Info("Shutting down GUI");
|
||||
gui::shutdown();
|
||||
#endif
|
||||
if (!hack::game_shutdown)
|
||||
{
|
||||
logging::Info("Running shutdown handlers");
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include <colors.hpp>
|
||||
#include <init.hpp>
|
||||
#include "KeyValues.h"
|
||||
#include "HookTools.hpp"
|
||||
|
||||
namespace event_logging
|
||||
{
|
||||
@ -253,7 +254,11 @@ public:
|
||||
|
||||
static LoggingEventListener event_listener{};
|
||||
|
||||
InitRoutine init([]() { g_IGameEventManager->AddListener(&event_listener, false); });
|
||||
InitRoutine init([]() {
|
||||
g_IGameEventManager->AddListener(&event_listener, false);
|
||||
EC::Register(
|
||||
EC::Shutdown, []() { g_IGameEventManager->RemoveListener(&event_listener); }, "shutdown_eventlogger");
|
||||
});
|
||||
|
||||
bool isEnabled()
|
||||
{
|
||||
|
@ -146,6 +146,11 @@ void gui::init()
|
||||
init_done = true;
|
||||
}
|
||||
|
||||
void gui::shutdown()
|
||||
{
|
||||
g_IGameEventManager->RemoveListener(&listener);
|
||||
}
|
||||
|
||||
void gui::draw()
|
||||
{
|
||||
if (!init_done)
|
||||
|
Reference in New Issue
Block a user