From 5accca385ce148bb56545e0d9fbb0037665be3b3 Mon Sep 17 00:00:00 2001 From: scrawl Date: Mon, 2 Apr 2012 13:47:25 +0200 Subject: [PATCH] fix crash on exit when no user settings exist --- apps/openmw/engine.cpp | 9 ++++++--- components/settings/settings.cpp | 5 ----- components/settings/settings.hpp | 3 --- 3 files changed, 6 insertions(+), 11 deletions(-) diff --git a/apps/openmw/engine.cpp b/apps/openmw/engine.cpp index 849ccbe2e..25c0c60bd 100644 --- a/apps/openmw/engine.cpp +++ b/apps/openmw/engine.cpp @@ -315,7 +315,7 @@ void OMW::Engine::go() boost::filesystem::create_directories(configPath); } - // Create the settings manager and load default and user settings file + // Create the settings manager and load default settings file Settings::Manager settings; const std::string localdefault = mCfgMgr.getLocalPath().string() + "/settings-default.cfg"; const std::string globaldefault = mCfgMgr.getGlobalPath().string() + "/settings-default.cfg"; @@ -326,11 +326,14 @@ void OMW::Engine::go() else if (boost::filesystem::exists(globaldefault)) settings.loadDefault(globaldefault); + // load user settings if they exist, otherwise just load the default settings as user settings const std::string settingspath = mCfgMgr.getUserPath().string() + "/settings.cfg"; if (boost::filesystem::exists(settingspath)) settings.loadUser(settingspath); - else - settings.copyDefaultToUserSettings(); + else if (boost::filesystem::exists(localdefault)) + settings.loadUser(localdefault); + else if (boost::filesystem::exists(globaldefault)) + settings.loadUser(globaldefault); mOgre->configure(!boost::filesystem::is_regular_file(mCfgMgr.getOgreConfigPath()), mCfgMgr.getOgreConfigPath().string(), diff --git a/components/settings/settings.cpp b/components/settings/settings.cpp index d94e06678..28201eda2 100644 --- a/components/settings/settings.cpp +++ b/components/settings/settings.cpp @@ -22,11 +22,6 @@ void Manager::loadDefault (const std::string& file) mDefaultFile.load(file); } -void Manager::copyDefaultToUserSettings () -{ - mFile = mDefaultFile; -} - void Manager::saveUser(const std::string& file) { std::fstream fout(file.c_str(), std::ios::out); diff --git a/components/settings/settings.hpp b/components/settings/settings.hpp index f670ea1dd..e9858eb94 100644 --- a/components/settings/settings.hpp +++ b/components/settings/settings.hpp @@ -27,9 +27,6 @@ namespace Settings void loadDefault (const std::string& file); ///< load file as the default settings (can be overridden by user settings) - void copyDefaultToUserSettings (); - ///< copy the default settings to the user settings (useful when there are no user settings yet) - void loadUser (const std::string& file); ///< load file as user settings