From 4fb9c0750cbe1b78ff63ac26902db00033978de4 Mon Sep 17 00:00:00 2001 From: WrinklyNinja Date: Sun, 31 Aug 2014 10:34:22 +0100 Subject: [PATCH] Attempted fix for plugin loading crash. #269 in tracker. --- src/backend/game.cpp | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/src/backend/game.cpp b/src/backend/game.cpp index 0892806f..335acc4f 100644 --- a/src/backend/game.cpp +++ b/src/backend/game.cpp @@ -743,7 +743,15 @@ namespace loot { BOOST_LOG_TRIVIAL(trace) << "Creating individual loading thread for: " << pluginPair.first; group.create_thread([this, plugin, headersOnly]() { BOOST_LOG_TRIVIAL(trace) << "Loading " << plugin.first->second.Name() << " individually."; - plugin.first->second = Plugin(*this, plugin.first->second.Name(), headersOnly); + try { + plugin.first->second = Plugin(*this, plugin.first->second.Name(), headersOnly); + } + catch (exception &e) { + BOOST_LOG_TRIVIAL(error) << plugin.first->second.Name() << ": Exception occurred: " << e.what(); + Plugin p; + p.Messages(list(1, Message(Message::error, string("An exception occurred while loading this plugin. Details: ") + e.what()))); + plugin.first->second = p; + } }); } else { @@ -752,9 +760,16 @@ namespace loot { } group.create_thread([this, &groupPlugins, headersOnly]() { for (auto plugin : groupPlugins) { - const std::string name = plugin->Name(); BOOST_LOG_TRIVIAL(trace) << "Loading " << plugin->Name() << " as part of a group."; - *plugin = Plugin(*this, name, headersOnly); + try { + *plugin = Plugin(*this, plugin->Name(), headersOnly); + } + catch (exception &e) { + BOOST_LOG_TRIVIAL(error) << plugin->Name() << ": Exception occurred: " << e.what(); + Plugin p; + p.Messages(list(1, Message(Message::error, string("An exception occurred while loading this plugin. Details: ") + e.what()))); + *plugin = p; + } } });