From 66a2fe6308d509bf99f483307c77ffc0febe39a0 Mon Sep 17 00:00:00 2001 From: leper Date: Mon, 15 Sep 2014 01:27:06 +0000 Subject: [PATCH] Unload hotkeys on shutdown. Fixes double registration of hotkeys on engine restart. This was SVN commit r15755. --- source/ps/GameSetup/GameSetup.cpp | 2 ++ source/ps/Hotkey.cpp | 8 +++++++- source/ps/Hotkey.h | 3 ++- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/source/ps/GameSetup/GameSetup.cpp b/source/ps/GameSetup/GameSetup.cpp index f1ff24a0ff..c35e22bb56 100644 --- a/source/ps/GameSetup/GameSetup.cpp +++ b/source/ps/GameSetup/GameSetup.cpp @@ -582,6 +582,8 @@ static void ShutdownPs() { SAFE_DELETE(g_GUI); + UnloadHotkeys(); + SAFE_DELETE(g_Console); // disable the special Windows cursor, or free textures for OGL cursors diff --git a/source/ps/Hotkey.cpp b/source/ps/Hotkey.cpp index 02db53f688..ef37f7d337 100644 --- a/source/ps/Hotkey.cpp +++ b/source/ps/Hotkey.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2013 Wildfire Games. +/* Copyright (C) 2014 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -172,6 +172,12 @@ void LoadHotkeys() } } +void UnloadHotkeys() +{ + g_HotkeyMap.clear(); + g_HotkeyStatus.clear(); +} + bool isNegated(const SKey& key) { // Normal keycodes are below EXTRA_KEYS_BASE diff --git a/source/ps/Hotkey.h b/source/ps/Hotkey.h index 27676510fd..cfad324af8 100644 --- a/source/ps/Hotkey.h +++ b/source/ps/Hotkey.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2012 Wildfire Games. +/* Copyright (C) 2014 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -42,6 +42,7 @@ const int SDL_HOTKEYDOWN = SDL_USEREVENT; const int SDL_HOTKEYUP = SDL_USEREVENT + 1; extern void LoadHotkeys(); +extern void UnloadHotkeys(); extern InReaction HotkeyInputHandler(const SDL_Event_* ev); extern bool HotkeyIsPressed(const CStr& keyname);