Fix a bug introduced in aseprite 0.9.2, commit 8a1295c0250d1cbb7982220931262458b1ceed8c.

Widget::getMnemonicChar() can return 0, and we should pre-check this
value before we compare the mnemonic with the pressed ascii char.
This commit is contained in:
David Capello 2012-07-17 23:00:55 -03:00
parent b090629897
commit 5da37e237b
2 changed files with 7 additions and 6 deletions

View File

@ -1211,7 +1211,8 @@ static MenuItem* check_for_letter(Menu* menu, int ascii)
continue;
MenuItem* menuitem = static_cast<MenuItem*>(child);
if (menuitem->getMnemonicChar() == tolower(ascii))
int mnemonic = menuitem->getMnemonicChar();
if (mnemonic > 0 && mnemonic == tolower(ascii))
return menuitem;
}
return NULL;

View File

@ -1200,10 +1200,9 @@ bool Widget::hasCapture()
int Widget::getMnemonicChar() const
{
if (hasText()) {
const char* text = getText();
for (int c=0; text[c]; ++c)
if ((text[c] == '&') && (text[c+1] != '&'))
return tolower(text[c+1]);
for (int c=0; m_text[c]; ++c)
if ((m_text[c] == '&') && (m_text[c+1] != '&'))
return tolower(m_text[c+1]);
}
return 0;
}
@ -1218,7 +1217,8 @@ bool Widget::isScancodeMnemonic(int scancode) const
else
return false;
return (getMnemonicChar() == ascii);
int mnemonic = getMnemonicChar();
return (mnemonic > 0 && mnemonic == ascii);
}
/**********************************************************************/