Code cleanup.

This commit is contained in:
spx 2011-09-04 18:06:19 +00:00
parent 1f8e3b81ec
commit e258dc9137
3 changed files with 19 additions and 24 deletions

View File

@ -2149,15 +2149,7 @@ int CRainmeter::Initialize(HWND Parent, HINSTANCE Instance, LPCSTR szPath)
}
// Create meter windows for active configs
std::multimap<int, int>::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<int, int>::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<int, int>::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)

View File

@ -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);

View File

@ -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;