diff options
author | Tarek Soliman | 2012-01-07 22:07:16 -0600 |
---|---|---|
committer | Tarek Soliman | 2012-01-07 22:08:57 -0600 |
commit | 37d77253cfd5cc1c7bef635d4d5bd05eb53ac02c (patch) | |
tree | 513c31b57190ae19e326f4be60371fb7a1b141a8 /backends/keymapper | |
parent | d143872be605b881eaec63b0168c9d4d551787ee (diff) | |
download | scummvm-rg350-37d77253cfd5cc1c7bef635d4d5bd05eb53ac02c.tar.gz scummvm-rg350-37d77253cfd5cc1c7bef635d4d5bd05eb53ac02c.tar.bz2 scummvm-rg350-37d77253cfd5cc1c7bef635d4d5bd05eb53ac02c.zip |
KEYMAPPER: Add failsafe code for popping into Keymapper itself
Thanks LordHoto
Diffstat (limited to 'backends/keymapper')
-rw-r--r-- | backends/keymapper/keymapper.cpp | 16 | ||||
-rw-r--r-- | backends/keymapper/keymapper.h | 5 |
2 files changed, 17 insertions, 4 deletions
diff --git a/backends/keymapper/keymapper.cpp b/backends/keymapper/keymapper.cpp index f950b1f4a2..38711343c2 100644 --- a/backends/keymapper/keymapper.cpp +++ b/backends/keymapper/keymapper.cpp @@ -163,9 +163,19 @@ void Keymapper::pushKeymap(Keymap *newMap, bool transparent, bool global) { _activeMaps.push(mr); } -void Keymapper::popKeymap() { - if (!_activeMaps.empty()) - _activeMaps.pop(); +void Keymapper::popKeymap(const char *name) { + if (!_activeMaps.empty()) { + if (name) { + String topKeymapName = _activeMaps.top().keymap->getName(); + if (topKeymapName.equals(name)) + _activeMaps.pop(); + else + warning("An attempt to pop wrong keymap was blocked (expected %s but was %s)", name, topKeymapName.c_str()); + } else { + _activeMaps.pop(); + } + } + } bool Keymapper::notifyEvent(const Common::Event &ev) { diff --git a/backends/keymapper/keymapper.h b/backends/keymapper/keymapper.h index cd060a413c..d2aa89cad6 100644 --- a/backends/keymapper/keymapper.h +++ b/backends/keymapper/keymapper.h @@ -131,8 +131,11 @@ public: /** * Pop the top keymap off the active stack. + * @param name (optional) name of keymap expected to be popped + * if provided, will not pop unless name is the same + * as the top keymap */ - void popKeymap(); + void popKeymap(const char *name = 0); // Implementation of the EventMapper interface bool notifyEvent(const Common::Event &ev); |