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 init();
|
||||||
|
void shutdown();
|
||||||
void draw();
|
void draw();
|
||||||
bool handleSdlEvent(SDL_Event *event);
|
bool handleSdlEvent(SDL_Event *event);
|
||||||
|
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
#include "hack.hpp"
|
#include "hack.hpp"
|
||||||
#include "common.hpp"
|
#include "common.hpp"
|
||||||
#include "MiscTemporary.hpp"
|
#include "MiscTemporary.hpp"
|
||||||
|
#include "menu/GuiInterface.hpp"
|
||||||
#include <link.h>
|
#include <link.h>
|
||||||
#include <pwd.h>
|
#include <pwd.h>
|
||||||
|
|
||||||
@ -400,6 +401,10 @@ void hack::Shutdown()
|
|||||||
delete g_pLocalPlayer;
|
delete g_pLocalPlayer;
|
||||||
delete g_pTeamRoundTimer;
|
delete g_pTeamRoundTimer;
|
||||||
delete g_pPlayerResource;
|
delete g_pPlayerResource;
|
||||||
|
#if ENABLE_GUI
|
||||||
|
logging::Info("Shutting down GUI");
|
||||||
|
gui::shutdown();
|
||||||
|
#endif
|
||||||
if (!hack::game_shutdown)
|
if (!hack::game_shutdown)
|
||||||
{
|
{
|
||||||
logging::Info("Running shutdown handlers");
|
logging::Info("Running shutdown handlers");
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
#include <colors.hpp>
|
#include <colors.hpp>
|
||||||
#include <init.hpp>
|
#include <init.hpp>
|
||||||
#include "KeyValues.h"
|
#include "KeyValues.h"
|
||||||
|
#include "HookTools.hpp"
|
||||||
|
|
||||||
namespace event_logging
|
namespace event_logging
|
||||||
{
|
{
|
||||||
@ -253,7 +254,11 @@ public:
|
|||||||
|
|
||||||
static LoggingEventListener event_listener{};
|
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()
|
bool isEnabled()
|
||||||
{
|
{
|
||||||
|
@ -146,6 +146,11 @@ void gui::init()
|
|||||||
init_done = true;
|
init_done = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void gui::shutdown()
|
||||||
|
{
|
||||||
|
g_IGameEventManager->RemoveListener(&listener);
|
||||||
|
}
|
||||||
|
|
||||||
void gui::draw()
|
void gui::draw()
|
||||||
{
|
{
|
||||||
if (!init_done)
|
if (!init_done)
|
||||||
|
Reference in New Issue
Block a user