From 5bef43ac14cb1e820d99335d4fcb8d8bb196b80a Mon Sep 17 00:00:00 2001 From: cc9cii Date: Thu, 30 Jul 2015 16:30:59 +1000 Subject: [PATCH] Remove duplicated config scanning (see: https://forum.openmw.org/viewtopic.php?f=7&t=2922&p=32940#p32940) * Requires boost::filesystem::canonical() from v1.48 * reduces startup time * Fixes asset files being listed multiple times in tables --- apps/opencs/editor.cpp | 10 +++++++++- components/files/configurationmanager.cpp | 18 ++++++++++++++---- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/apps/opencs/editor.cpp b/apps/opencs/editor.cpp index 0bcaff6a52..c70b3dd19e 100644 --- a/apps/opencs/editor.cpp +++ b/apps/opencs/editor.cpp @@ -159,15 +159,23 @@ std::pair > CS::Editor::readConfi } dataDirs.insert (dataDirs.end(), dataLocal.begin(), dataLocal.end()); + Files::PathContainer canonicalPaths; //iterate the data directories and add them to the file dialog for loading for (Files::PathContainer::const_iterator iter = dataDirs.begin(); iter != dataDirs.end(); ++iter) { + boost::filesystem::path p = boost::filesystem::canonical(*iter); + Files::PathContainer::iterator it = std::find(canonicalPaths.begin(), canonicalPaths.end(), p); + if (it == canonicalPaths.end()) + canonicalPaths.push_back(p); + else + continue; + QString path = QString::fromUtf8 (iter->string().c_str()); mFileDialog.addFiles(path); } - return std::make_pair (dataDirs, variables["fallback-archive"].as >()); + return std::make_pair (canonicalPaths, variables["fallback-archive"].as >()); } void CS::Editor::createGame() diff --git a/components/files/configurationmanager.cpp b/components/files/configurationmanager.cpp index dc6f02b608..ac461697aa 100644 --- a/components/files/configurationmanager.cpp +++ b/components/files/configurationmanager.cpp @@ -57,14 +57,24 @@ void ConfigurationManager::readConfiguration(boost::program_options::variables_m bool silent = mSilent; mSilent = quiet; + boost::filesystem::path pUser = boost::filesystem::canonical(mFixedPath.getUserConfigPath()); + boost::filesystem::path pLocal = boost::filesystem::canonical(mFixedPath.getLocalPath()); + boost::filesystem::path pGlobal = boost::filesystem::canonical(mFixedPath.getGlobalConfigPath()); + loadConfig(mFixedPath.getUserConfigPath(), variables, description); boost::program_options::notify(variables); - loadConfig(mFixedPath.getLocalPath(), variables, description); - boost::program_options::notify(variables); - loadConfig(mFixedPath.getGlobalConfigPath(), variables, description); - boost::program_options::notify(variables); + if (pLocal != pUser) + { + loadConfig(mFixedPath.getLocalPath(), variables, description); + boost::program_options::notify(variables); + } + if (pGlobal != pUser && pGlobal != pLocal) + { + loadConfig(mFixedPath.getGlobalConfigPath(), variables, description); + boost::program_options::notify(variables); + } mSilent = silent; }