Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions core/MenuStyle_Base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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)
Expand Down
9 changes: 9 additions & 0 deletions core/MenuVoting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
#include <const.h>
#include <ITranslator.h>
#include "logic_bridge.h"
#include "AutoHandleRooter.h"

float g_next_vote = 0.0f;

Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
Expand Down
23 changes: 0 additions & 23 deletions core/logic/HandleSys.h
Original file line number Diff line number Diff line change
Expand Up @@ -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_