From: <man...@us...> - 2015-06-15 17:18:58
|
Revision: 5322 http://sourceforge.net/p/modplug/code/5322 Author: manxorist Date: 2015-06-15 17:18:52 +0000 (Mon, 15 Jun 2015) Log Message: ----------- [Ref] Split class DebugSettings from class TrackerSettings and initialize the former first. Modified Paths: -------------- trunk/OpenMPT/mptrack/Mptrack.cpp trunk/OpenMPT/mptrack/Mptrack.h trunk/OpenMPT/mptrack/TrackerSettings.cpp trunk/OpenMPT/mptrack/TrackerSettings.h Modified: trunk/OpenMPT/mptrack/Mptrack.cpp =================================================================== --- trunk/OpenMPT/mptrack/Mptrack.cpp 2015-06-15 16:36:08 UTC (rev 5321) +++ trunk/OpenMPT/mptrack/Mptrack.cpp 2015-06-15 17:18:52 UTC (rev 5322) @@ -651,6 +651,7 @@ , m_pSettingsIniFile(nullptr) , m_pSongSettings(nullptr) , m_pSettings(nullptr) + , m_pDebugSettings(nullptr) , m_pTrackerSettings(nullptr) , m_pComponentManagerSettings(nullptr) , m_pPluginCache(nullptr) @@ -932,24 +933,12 @@ m_pSettingsIniFile = new IniFileSettingsBackend(m_szConfigFileName); m_pSettings = new SettingsContainer(m_pSettingsIniFile); + + m_pDebugSettings = new DebugSettings(*m_pSettings); + m_pTrackerSettings = new TrackerSettings(*m_pSettings); - // enable debug features (as early as possible after reading the settings) - #if !defined(NO_LOGGING) && !defined(MPT_LOG_IS_DISABLED) - #if !defined(MPT_LOG_GLOBAL_LEVEL_STATIC) - mpt::log::GlobalLogLevel = TrackerSettings::Instance().DebugLogLevel; - #endif - mpt::log::SetFacilities(TrackerSettings::Instance().DebugLogFacilitySolo, TrackerSettings::Instance().DebugLogFacilityBlocked); - mpt::log::FileEnabled = TrackerSettings::Instance().DebugLogFileEnable; - mpt::log::DebuggerEnabled = TrackerSettings::Instance().DebugLogDebuggerEnable; - mpt::log::ConsoleEnabled = TrackerSettings::Instance().DebugLogConsoleEnable; - #endif MPT_LOG(LogInformation, "", MPT_USTRING("OpenMPT settings initialized.")); - if(TrackerSettings::Instance().DebugTraceEnable) - { - mpt::log::Trace::Enable(TrackerSettings::Instance().DebugTraceSize); - } - MPT_TRACE(); // Create missing diretories if(!TrackerSettings::Instance().PathTunings.GetDefaultDir().IsDirectory()) @@ -1146,17 +1135,14 @@ ComponentManager::Release(); - if(TrackerSettings::Instance().DebugTraceAlwaysDump) - { - DebugTraceDump(); - } - delete m_pPluginCache; m_pPluginCache = nullptr; delete m_pComponentManagerSettings; m_pComponentManagerSettings = nullptr; delete m_pTrackerSettings; m_pTrackerSettings = nullptr; + delete m_pDebugSettings; + m_pDebugSettings = nullptr; delete m_pSettings; m_pSettings = nullptr; delete m_pSettingsIniFile; Modified: trunk/OpenMPT/mptrack/Mptrack.h =================================================================== --- trunk/OpenMPT/mptrack/Mptrack.h 2015-06-15 16:36:08 UTC (rev 5321) +++ trunk/OpenMPT/mptrack/Mptrack.h 2015-06-15 17:18:52 UTC (rev 5322) @@ -28,6 +28,7 @@ class Manager; } // namespace SoundDevice class CDLSBank; +class DebugSettings; class TrackerSettings; class ComponentManagerSettings; @@ -203,6 +204,7 @@ IniFileSettingsBackend *m_pSettingsIniFile; SettingsContainer *m_pSettings; + DebugSettings *m_pDebugSettings; TrackerSettings *m_pTrackerSettings; IniFileSettingsBackend *m_pSongSettingsIniFile; SettingsContainer *m_pSongSettings; Modified: trunk/OpenMPT/mptrack/TrackerSettings.cpp =================================================================== --- trunk/OpenMPT/mptrack/TrackerSettings.cpp 2015-06-15 16:36:08 UTC (rev 5321) +++ trunk/OpenMPT/mptrack/TrackerSettings.cpp 2015-06-15 17:18:52 UTC (rev 5322) @@ -131,6 +131,57 @@ } +DebugSettings::DebugSettings(SettingsContainer &conf) +//--------------------------------------------------- + : conf(conf) + // Debug +#if !defined(NO_LOGGING) && !defined(MPT_LOG_IS_DISABLED) + , DebugLogLevel(conf, "Debug", "LogLevel", static_cast<int>(mpt::log::GlobalLogLevel)) + , DebugLogFacilitySolo(conf, "Debug", "LogFacilitySolo", std::string()) + , DebugLogFacilityBlocked(conf, "Debug", "LogFacilityBlocked", std::string()) + , DebugLogFileEnable(conf, "Debug", "LogFileEnable", mpt::log::FileEnabled) + , DebugLogDebuggerEnable(conf, "Debug", "LogDebuggerEnable", mpt::log::DebuggerEnabled) + , DebugLogConsoleEnable(conf, "Debug", "LogConsoleEnable", mpt::log::ConsoleEnabled) +#endif + , DebugTraceEnable(conf, "Debug", "TraceEnable", false) + , DebugTraceSize(conf, "Debug", "TraceSize", 1000000) + , DebugTraceAlwaysDump(conf, "Debug", "TraceAlwaysDump", false) + , DebugStopSoundDeviceOnCrash(conf, "Debug", "StopSoundDeviceOnCrash", true) + , DebugStopSoundDeviceBeforeDump(conf, "Debug", "StopSoundDeviceBeforeDump", false) +{ + + // Duplicate state for debug stuff in order to avoid calling into settings framework from crash context. + ExceptionHandler::stopSoundDeviceOnCrash = DebugStopSoundDeviceOnCrash; + ExceptionHandler::stopSoundDeviceBeforeDump = DebugStopSoundDeviceBeforeDump; + + // enable debug features (as early as possible after reading the settings) + #if !defined(NO_LOGGING) && !defined(MPT_LOG_IS_DISABLED) + #if !defined(MPT_LOG_GLOBAL_LEVEL_STATIC) + mpt::log::GlobalLogLevel = DebugLogLevel; + #endif + mpt::log::SetFacilities(DebugLogFacilitySolo, DebugLogFacilityBlocked); + mpt::log::FileEnabled = DebugLogFileEnable; + mpt::log::DebuggerEnabled = DebugLogDebuggerEnable; + mpt::log::ConsoleEnabled = DebugLogConsoleEnable; + #endif + if(DebugTraceEnable) + { + mpt::log::Trace::Enable(DebugTraceSize); + } + +} + + +DebugSettings::~DebugSettings() +//----------------------------- +{ + if(DebugTraceAlwaysDump) + { + DebugTraceDump(); + } +} + + TrackerSettings::TrackerSettings(SettingsContainer &conf) //------------------------------------------------------- : conf(conf) @@ -260,27 +311,8 @@ , UpdateUpdateURL(conf, "Update", "UpdateURL", CUpdateCheck::GetUpdateURL()) , UpdateSendGUID(conf, "Update", "SendGUID", CUpdateCheck::GetSendGUID()) , UpdateShowUpdateHint(conf, "Update", "ShowUpdateHint", CUpdateCheck::GetShowUpdateHint()) - // Debug -#if !defined(NO_LOGGING) && !defined(MPT_LOG_IS_DISABLED) - , DebugLogLevel(conf, "Debug", "LogLevel", static_cast<int>(mpt::log::GlobalLogLevel)) - , DebugLogFacilitySolo(conf, "Debug", "LogFacilitySolo", std::string()) - , DebugLogFacilityBlocked(conf, "Debug", "LogFacilityBlocked", std::string()) - , DebugLogFileEnable(conf, "Debug", "LogFileEnable", mpt::log::FileEnabled) - , DebugLogDebuggerEnable(conf, "Debug", "LogDebuggerEnable", mpt::log::DebuggerEnabled) - , DebugLogConsoleEnable(conf, "Debug", "LogConsoleEnable", mpt::log::ConsoleEnabled) -#endif - , DebugTraceEnable(conf, "Debug", "TraceEnable", false) - , DebugTraceSize(conf, "Debug", "TraceSize", 1000000) - , DebugTraceAlwaysDump(conf, "Debug", "TraceAlwaysDump", false) - , DebugStopSoundDeviceOnCrash(conf, "Debug", "StopSoundDeviceOnCrash", true) - , DebugStopSoundDeviceBeforeDump(conf, "Debug", "StopSoundDeviceBeforeDump", false) { - // Debug - // Duplicate state for debug stuff in order to avoid calling into settings framework from crash context. - ExceptionHandler::stopSoundDeviceOnCrash = DebugStopSoundDeviceOnCrash; - ExceptionHandler::stopSoundDeviceBeforeDump = DebugStopSoundDeviceBeforeDump; - // Effects #ifndef NO_DSP m_DSPSettings.m_nXBassDepth = conf.Read<int32>("Effects", "XBassDepth", m_DSPSettings.m_nXBassDepth); Modified: trunk/OpenMPT/mptrack/TrackerSettings.h =================================================================== --- trunk/OpenMPT/mptrack/TrackerSettings.h 2015-06-15 16:36:08 UTC (rev 5321) +++ trunk/OpenMPT/mptrack/TrackerSettings.h 2015-06-15 17:18:52 UTC (rev 5322) @@ -433,6 +433,44 @@ }; +//================= +class DebugSettings +//================= +{ + +private: + + SettingsContainer &conf; + +private: + + // Debug + +#if !defined(NO_LOGGING) && !defined(MPT_LOG_IS_DISABLED) + Setting<int> DebugLogLevel; + Setting<std::string> DebugLogFacilitySolo; + Setting<std::string> DebugLogFacilityBlocked; + Setting<bool> DebugLogFileEnable; + Setting<bool> DebugLogDebuggerEnable; + Setting<bool> DebugLogConsoleEnable; +#endif + + Setting<bool> DebugTraceEnable; + Setting<uint32> DebugTraceSize; + Setting<bool> DebugTraceAlwaysDump; + + Setting<bool> DebugStopSoundDeviceOnCrash; + Setting<bool> DebugStopSoundDeviceBeforeDump; + +public: + + DebugSettings(SettingsContainer &conf); + + ~DebugSettings(); + +}; + + //=================== class TrackerSettings //=================== @@ -643,24 +681,6 @@ Setting<bool> UpdateSendGUID; Setting<bool> UpdateShowUpdateHint; - // Debug - -#if !defined(NO_LOGGING) && !defined(MPT_LOG_IS_DISABLED) - Setting<int> DebugLogLevel; - Setting<std::string> DebugLogFacilitySolo; - Setting<std::string> DebugLogFacilityBlocked; - Setting<bool> DebugLogFileEnable; - Setting<bool> DebugLogDebuggerEnable; - Setting<bool> DebugLogConsoleEnable; -#endif - - Setting<bool> DebugTraceEnable; - Setting<uint32> DebugTraceSize; - Setting<bool> DebugTraceAlwaysDump; - - Setting<bool> DebugStopSoundDeviceOnCrash; - Setting<bool> DebugStopSoundDeviceBeforeDump; - public: TrackerSettings(SettingsContainer &conf); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |