Fix crash in SelectAccelerator::KeyField when a Unicode char is pressed

The problem is that Accelerator::toString() wasn't returning valid utf-8
strings for Unicode characters.
This commit is contained in:
David Capello 2014-11-01 15:46:13 -03:00
parent 58b89ded4a
commit ef25706ed2

View File

@ -322,8 +322,11 @@ std::string Accelerator::toString() const
if (m_modifiers & kKeySpaceModifier) buf += "Space+"; if (m_modifiers & kKeySpaceModifier) buf += "Space+";
// Key // Key
if (m_unicodeChar) if (m_unicodeChar) {
buf += (wchar_t)toupper(m_unicodeChar); std::wstring wideUnicodeChar;
wideUnicodeChar.push_back((wchar_t)toupper(m_unicodeChar));
buf += base::to_utf8(wideUnicodeChar);
}
else if (m_scancode && m_scancode > 0 && m_scancode < (int)table_size) else if (m_scancode && m_scancode > 0 && m_scancode < (int)table_size)
buf += table[m_scancode]; buf += table[m_scancode];
else if (!buf.empty() && buf[buf.size()-1] == '+') else if (!buf.empty() && buf[buf.size()-1] == '+')