Fixed that !RainmeterSetVariable and !RainmeterWriteKeyValue are unable to set/write empty value (thanks spx!).

This commit is contained in:
Birunthan Mohanathas 2011-01-27 15:23:15 +00:00
parent c24a3c025f
commit ce614da5f3
2 changed files with 20 additions and 12 deletions

View File

@ -54,9 +54,6 @@ std::vector<std::wstring> CRainmeter::ParseString(LPCTSTR str)
while (quotePos != std::wstring::npos || spacePos != std::wstring::npos) while (quotePos != std::wstring::npos || spacePos != std::wstring::npos)
{ {
size_t endPos = 0; size_t endPos = 0;
std::wstring newStr;
if (spacePos == std::wstring::npos) spacePos = arg.size() - 1;
if (quotePos == 0) if (quotePos == 0)
{ {
@ -65,17 +62,18 @@ std::vector<std::wstring> CRainmeter::ParseString(LPCTSTR str)
// Find the second quote // Find the second quote
quotePos = arg.find(L"\""); quotePos = arg.find(L"\"");
endPos = quotePos; endPos = quotePos;
newStr = arg.substr(0, endPos);
arg.erase(0, endPos + 1);
} }
else else
{ {
if (spacePos == std::wstring::npos) spacePos = arg.size() - 1;
endPos = spacePos; endPos = spacePos;
newStr = arg.substr(0, endPos);
arg.erase(0, endPos + 1);
} }
if (newStr.size() > 0) std::wstring newStr = arg.substr(0, endPos);
arg.erase(0, endPos + 1);
if (newStr.size() > 0 || quotePos == 0)
{ {
result.push_back(newStr); result.push_back(newStr);
} }
@ -124,8 +122,8 @@ int initModuleEx(HWND ParentWnd, HINSTANCE dllInst, LPCSTR szPath)
} }
} }
catch(CError& error) catch(CError& error)
{ {
MessageBox(ParentWnd, error.GetString().c_str(), APPNAME, MB_OK | MB_TOPMOST | MB_ICONEXCLAMATION); MessageBox(ParentWnd, error.GetString().c_str(), APPNAME, MB_OK | MB_TOPMOST | MB_ICONEXCLAMATION);
} }

View File

@ -130,7 +130,17 @@ LPCTSTR GetString(UINT id, UINT flags)
*/ */
void Finalize(HMODULE instance, UINT id) void Finalize(HMODULE instance, UINT id)
{ {
/* Nothing to do here */ std::map<UINT, eMeasureType>::iterator i1 = g_Types.find(id);
if (i1 != g_Types.end())
{
g_Types.erase(i1);
}
std::map<UINT, int>::iterator i2 = g_Indexes.find(id);
if (i2 != g_Indexes.end())
{
g_Indexes.erase(i2);
}
} }
/* /*