From: <man...@us...> - 2014-03-24 12:50:38
|
Revision: 3956 http://sourceforge.net/p/modplug/code/3956 Author: manxorist Date: 2014-03-24 12:50:32 +0000 (Mon, 24 Mar 2014) Log Message: ----------- [Imp] settings: Add a SettingFlushMode parameter to SettingsContainer::Write . [Fix] Plugin manager: Immediately write the FailedPlugin ID to the INI file, otherwise it gets forgotten when loadind actually crashes. Modified Paths: -------------- trunk/OpenMPT/mptrack/Settings.cpp trunk/OpenMPT/mptrack/Settings.h trunk/OpenMPT/soundlib/plugins/PluginManager.cpp Modified: trunk/OpenMPT/mptrack/Settings.cpp =================================================================== --- trunk/OpenMPT/mptrack/Settings.cpp 2014-03-24 12:35:07 UTC (rev 3955) +++ trunk/OpenMPT/mptrack/Settings.cpp 2014-03-24 12:50:32 UTC (rev 3956) @@ -151,7 +151,7 @@ return entry->second; } -void SettingsContainer::WriteSetting(const SettingPath &path, const SettingValue &val) +void SettingsContainer::WriteSetting(const SettingPath &path, const SettingValue &val, SettingFlushMode flushMode) { ASSERT(theApp.InGuiThread()); ASSERT(!CMainFrame::GetMainFrame() || (CMainFrame::GetMainFrame() && !CMainFrame::GetMainFrame()->InNotifyHandler())); // This is a slow path, use CachedSetting for stuff that is accessed in notify handler. @@ -165,7 +165,7 @@ entry->second = val; } NotifyListeners(path); - if(immediateFlush) + if(immediateFlush || flushMode == SettingWriteThrough) { BackendsWriteSetting(path, val); entry->second.Clean(); Modified: trunk/OpenMPT/mptrack/Settings.h =================================================================== --- trunk/OpenMPT/mptrack/Settings.h 2014-03-24 12:35:07 UTC (rev 3955) +++ trunk/OpenMPT/mptrack/Settings.h 2014-03-24 12:50:32 UTC (rev 3956) @@ -470,6 +470,12 @@ virtual void SettingChanged(const SettingPath &path) = 0; }; +enum SettingFlushMode +{ + SettingWriteBack = 0, + SettingWriteThrough = 1, +}; + // SettingContainer basically represents a frontend to 1 or 2 backends (e.g. ini files or registry subtrees) for a collection of configuration settings. // SettingContainer provides basic read/write access to individual setting. The values are cached and only flushed on destruction or explicit flushs. class SettingsContainer @@ -498,7 +504,7 @@ void BackendsRemoveSetting(const SettingPath &path); void NotifyListeners(const SettingPath &path); SettingValue ReadSetting(const SettingPath &path, const SettingValue &def, const SettingMetadata &metadata) const; - void WriteSetting(const SettingPath &path, const SettingValue &val); + void WriteSetting(const SettingPath &path, const SettingValue &val, SettingFlushMode flushMode); void ForgetSetting(const SettingPath &path); void RemoveSetting(const SettingPath &path); private: @@ -523,19 +529,19 @@ return FromSettingValue<T>(ReadSetting(SettingPath(section, key), ToSettingValue<T>(def), metadata)); } template <typename T> - void Write(const SettingPath &path, const T &val) + void Write(const SettingPath &path, const T &val, SettingFlushMode flushMode = SettingWriteBack) { - WriteSetting(path, ToSettingValue<T>(val)); + WriteSetting(path, ToSettingValue<T>(val), flushMode); } template <typename T> - void Write(const std::wstring §ion, const std::wstring &key, const T &val) + void Write(const std::wstring §ion, const std::wstring &key, const T &val, SettingFlushMode flushMode = SettingWriteBack) { - WriteSetting(SettingPath(section, key), ToSettingValue<T>(val)); + WriteSetting(SettingPath(section, key), ToSettingValue<T>(val), flushMode); } template <typename T> - void Write(const std::string §ion, const std::string &key, const T &val) + void Write(const std::string §ion, const std::string &key, const T &val, SettingFlushMode flushMode = SettingWriteBack) { - WriteSetting(SettingPath(section, key), ToSettingValue<T>(val)); + WriteSetting(SettingPath(section, key), ToSettingValue<T>(val), flushMode); } void Forget(const SettingPath &path) { Modified: trunk/OpenMPT/soundlib/plugins/PluginManager.cpp =================================================================== --- trunk/OpenMPT/soundlib/plugins/PluginManager.cpp 2014-03-24 12:35:07 UTC (rev 3955) +++ trunk/OpenMPT/soundlib/plugins/PluginManager.cpp 2014-03-24 12:50:32 UTC (rev 3956) @@ -376,7 +376,7 @@ } // If this key contains a file name on program launch, a plugin previously crashed OpenMPT. - theApp.GetSettings().Write<mpt::PathString>("VST Plugins", "FailedPlugin", dllPath); + theApp.GetSettings().Write<mpt::PathString>("VST Plugins", "FailedPlugin", dllPath, SettingWriteThrough); AEffect *pEffect; HINSTANCE hLib; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |