From e258dc9137f5a2fd4d30b8892cffe91f6213b82c Mon Sep 17 00:00:00 2001 From: spx Date: Sun, 4 Sep 2011 18:06:19 +0000 Subject: [PATCH] Code cleanup. --- Library/Rainmeter.cpp | 33 +++++++++++++++------------------ Library/Rainmeter.h | 1 + Library/System.cpp | 9 +++------ 3 files changed, 19 insertions(+), 24 deletions(-) diff --git a/Library/Rainmeter.cpp b/Library/Rainmeter.cpp index feda7293..f2688414 100644 --- a/Library/Rainmeter.cpp +++ b/Library/Rainmeter.cpp @@ -2149,15 +2149,7 @@ int CRainmeter::Initialize(HWND Parent, HINSTANCE Instance, LPCSTR szPath) } // Create meter windows for active configs - std::multimap::const_iterator iter = m_ConfigOrders.begin(); - for ( ; iter != m_ConfigOrders.end(); ++iter) - { - const CONFIG& config = m_ConfigStrings[(*iter).second]; - if (config.active > 0 && config.active <= (int)config.iniFiles.size()) - { - ActivateConfig((*iter).second, config.active - 1); - } - } + ActivateActiveConfigs(); return Result; // Alles OK } @@ -2195,6 +2187,19 @@ void CRainmeter::ReloadSettings() ReadGeneralSettings(m_IniFile); } +void CRainmeter::ActivateActiveConfigs() +{ + std::multimap::const_iterator iter = m_ConfigOrders.begin(); + for ( ; iter != m_ConfigOrders.end(); ++iter) + { + const CONFIG& config = m_ConfigStrings[(*iter).second]; + if (config.active > 0 && config.active <= (int)config.iniFiles.size()) + { + ActivateConfig((*iter).second, config.active - 1); + } + } +} + void CRainmeter::ActivateConfig(int configIndex, int iniIndex) { if (configIndex >= 0 && configIndex < (int)m_ConfigStrings.size()) @@ -3580,15 +3585,7 @@ void CRainmeter::LoadTheme(const std::wstring& name) ReloadSettings(); // Create meter windows for active configs - std::multimap::const_iterator iter = m_ConfigOrders.begin(); - for ( ; iter != m_ConfigOrders.end(); ++iter) - { - const CONFIG& config = m_ConfigStrings[(*iter).second]; - if (config.active > 0 && config.active <= (int)config.iniFiles.size()) - { - ActivateConfig((*iter).second, config.active - 1); - } - } + ActivateActiveConfigs(); } void CRainmeter::PreserveSetting(const std::wstring& from, LPCTSTR key, bool replace) diff --git a/Library/Rainmeter.h b/Library/Rainmeter.h index 13959627..19739a9f 100644 --- a/Library/Rainmeter.h +++ b/Library/Rainmeter.h @@ -268,6 +268,7 @@ public: friend class CDialogManage; private: + void ActivateActiveConfigs(); void CreateMeterWindow(const std::wstring& path, const std::wstring& config, const std::wstring& iniFile); bool DeleteMeterWindow(CMeterWindow* meterWindow, bool bLater); void WriteActive(const std::wstring& config, int iniIndex); diff --git a/Library/System.cpp b/Library/System.cpp index 812f1093..33e68891 100644 --- a/Library/System.cpp +++ b/Library/System.cpp @@ -1141,10 +1141,8 @@ bool CSystem::CopyFiles(const std::wstring& strFrom, const std::wstring& strTo, std::wstring tmpFrom(strFrom), tmpTo(strTo); // The strings must end with double nul - tmpFrom.append(L"0"); - tmpFrom[tmpFrom.size() - 1] = L'\0'; - tmpTo.append(L"0"); - tmpTo[tmpTo.size() - 1] = L'\0'; + tmpFrom.append(1, L'\0'); + tmpTo.append(1, L'\0'); SHFILEOPSTRUCT fo = {0}; fo.wFunc = bMove ? FO_MOVE : FO_COPY; @@ -1190,8 +1188,7 @@ bool CSystem::RemoveFolder(const std::wstring& strFolder) std::wstring tmpFolder(strFolder); // The strings must end with double nul - tmpFolder.append(L"0"); - tmpFolder[tmpFolder.size() - 1] = L'\0'; + tmpFolder.append(1, L'\0'); SHFILEOPSTRUCT fo = {0}; fo.wFunc = FO_DELETE;