From 51f859651dab6f0beeaba6444820c72d8beaef1c Mon Sep 17 00:00:00 2001 From: Jacob Essex Date: Wed, 9 Nov 2011 23:15:06 +0000 Subject: [PATCH] Exceptions from input handlers are now caught in OpenEngine as opposed to requring a try/catch in the input handler itself --- input/dispatcher.hpp | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/input/dispatcher.hpp b/input/dispatcher.hpp index dd6fb6bf6..2cd1ed5ae 100644 --- a/input/dispatcher.hpp +++ b/input/dispatcher.hpp @@ -47,7 +47,23 @@ struct Dispatcher : Mangle::Input::Event const _O &list = map.getList(index); _O::const_iterator it; for(it = list.begin(); it != list.end(); it++) - funcs.call(*it, p); + { + //catch exceptions thrown in the input handlers so that pressing a key + //doesn't cause OpenMw to crash + try + { + funcs.call(*it, p); + } + catch(const std::exception& e) + { + std::cerr << "Exception in input handler: " << e.what() << std::endl; + } + catch(...) + { + std::cerr << "Unknown exception in input handler" << std::endl; + } + + } } };