From 5aa4646ce6c2a140f78cbfb52445e510d09c262d Mon Sep 17 00:00:00 2001 From: WrinklyNinja Date: Mon, 14 Jul 2014 10:09:50 +0100 Subject: [PATCH] Fixed broken plugin loading. Some plugins were being repeated or overwritten. Masterlist messages are currently not being displayed for plugins in the report though, I think I know why. --- src/backend/game.cpp | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/backend/game.cpp b/src/backend/game.cpp index 56f34e07..5887ce3b 100644 --- a/src/backend/game.cpp +++ b/src/backend/game.cpp @@ -576,7 +576,7 @@ namespace loot { boost::thread_group group; size_t meanFileSize = 0; unordered_map tempMap; - std::set skipPlugins; + std::vector groupPlugins; //First calculate the mean plugin size. Store it temporarily in a map to reduce filesystem lookups and file size recalculation. for (fs::directory_iterator it(this->DataPath()); it != fs::directory_iterator(); ++it) { if (fs::is_regular_file(it->status()) && IsPlugin(it->path().string())) { @@ -597,19 +597,24 @@ namespace loot { auto plugin = plugins.emplace(pluginPair.first, Plugin(pluginPair.first)); if (pluginPair.second > meanFileSize) { - skipPlugins.insert(pluginPair.first); - group.create_thread([this, &plugin, headersOnly]() { + 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->first, headersOnly); }); } + else { + groupPlugins.push_back(&plugin.first->second); + } } - group.create_thread([this, &skipPlugins, headersOnly]() { - for (auto &pluginPair : this->plugins) { - if (skipPlugins.find(pluginPair.first) == skipPlugins.end()) { - pluginPair.second = Plugin(*this, pluginPair.first, headersOnly); - } + 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); } }); + group.join_all(); }