From ac58dd735b47ed16e33464bfc49437d07fa8d743 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Fri, 31 Oct 2014 11:02:42 +0100 Subject: [PATCH] do not crash on exceptions while adding startup scripts --- apps/openmw/mwscript/globalscripts.cpp | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/apps/openmw/mwscript/globalscripts.cpp b/apps/openmw/mwscript/globalscripts.cpp index 8270c4e6b2..d9778c053e 100644 --- a/apps/openmw/mwscript/globalscripts.cpp +++ b/apps/openmw/mwscript/globalscripts.cpp @@ -90,13 +90,32 @@ namespace MWScript void GlobalScripts::addStartup() { - addScript ("main"); + // make list of global scripts to be added + std::vector scripts; + + scripts.push_back ("main"); for (MWWorld::Store::iterator iter = mStore.get().begin(); iter != mStore.get().end(); ++iter) { - addScript (iter->mScript); + scripts.push_back (iter->mScript); + } + + // add scripts + for (std::vector::const_iterator iter (scripts.begin()); + iter!=scripts.end(); ++iter) + { + try + { + addScript (*iter); + } + catch (const std::exception& exception) + { + std::cerr + << "Failed to add start script " << *iter << " because an exception has " + << "been thrown: " << exception.what() << std::endl; + } } }