diff --git a/core/MenuStyle_Base.cpp b/core/MenuStyle_Base.cpp index 491bbe69b3..303634778c 100644 --- a/core/MenuStyle_Base.cpp +++ b/core/MenuStyle_Base.cpp @@ -97,6 +97,9 @@ void BaseMenuStyle::_CancelClientMenu(int client, MenuCancelReason reason, bool RemoveClientFromWatch(client); } + Handle_t hndl = menu ? menu->GetHandle() : BAD_HANDLE; + AutoHandleRooter ahr(hndl); + /* Fire callbacks */ mh->OnMenuCancel(menu, client, reason); @@ -576,6 +579,8 @@ bool BaseMenuStyle::RedoClientMenu(int client, ItemOrder order) CBaseMenuPlayer *player = GetMenuPlayer(client); menu_states_t &states = player->states; + AutoHandleRooter ahr(states.menu ? states.menu->GetHandle() : BAD_HANDLE); + player->bAutoIgnore = true; IMenuPanel *display = g_Menus.RenderMenu(client, states, order); if (!display) diff --git a/core/MenuVoting.cpp b/core/MenuVoting.cpp index de38a24e33..3b111d24ff 100644 --- a/core/MenuVoting.cpp +++ b/core/MenuVoting.cpp @@ -41,6 +41,7 @@ #include #include #include "logic_bridge.h" +#include "AutoHandleRooter.h" float g_next_vote = 0.0f; @@ -365,6 +366,11 @@ void VoteMenuHandler::StartVoting() m_pHandler->OnMenuVoteStart(m_pCurMenu); + if (!m_bStarted) + { + return; + } + m_displayTimer = g_Timers.CreateTimer(this, 1.0, NULL, TIMER_FLAG_REPEAT|TIMER_FLAG_NO_MAPCHANGE); /* By now we know how many clients were set. @@ -426,6 +432,7 @@ void VoteMenuHandler::EndVoting() IBaseMenu *menu = m_pCurMenu; IMenuHandler *handler = m_pHandler; InternalReset(); + AutoHandleRooter ahr(menu ? menu->GetHandle() : BAD_HANDLE); handler->OnMenuVoteCancel(menu, VoteCancel_Generic); handler->OnMenuEnd(menu, MenuEnd_VotingCancelled); return; @@ -455,6 +462,7 @@ void VoteMenuHandler::EndVoting() IBaseMenu *menu = m_pCurMenu; IMenuHandler *handler = m_pHandler; InternalReset(); + AutoHandleRooter ahr(menu ? menu->GetHandle() : BAD_HANDLE); handler->OnMenuVoteCancel(menu, VoteCancel_NoVotes); handler->OnMenuEnd(menu, MenuEnd_VotingCancelled); return; @@ -486,6 +494,7 @@ void VoteMenuHandler::EndVoting() InternalReset(); /* Send vote info */ + AutoHandleRooter ahr(menu ? menu->GetHandle() : BAD_HANDLE); handler->OnMenuVoteResults(menu, &vote); handler->OnMenuEnd(menu, MenuEnd_VotingDone); } diff --git a/core/logic/HandleSys.h b/core/logic/HandleSys.h index 2fc786b898..dee2f6e4c1 100644 --- a/core/logic/HandleSys.h +++ b/core/logic/HandleSys.h @@ -243,27 +243,4 @@ class HandleSystem : extern HandleSystem g_HandleSys; -struct AutoHandleRooter -{ -public: - AutoHandleRooter(Handle_t hndl) - { - if (hndl != BAD_HANDLE) - this->hndl = g_HandleSys.FastCloneHandle(hndl); - else - this->hndl = BAD_HANDLE; - } - - ~AutoHandleRooter() - { - if (hndl != BAD_HANDLE) - { - HandleSecurity sec(g_pCoreIdent, g_pCoreIdent); - g_HandleSys.FreeHandle(hndl, &sec); - } - } -private: - Handle_t hndl; -}; - #endif //_INCLUDE_SOURCEMOD_HANDLESYSTEM_H_