nemomobile / fingerterm

12 stars 29 forks source link

[terminal] Fix Terminal::keyPress() for non-ASCII chars (Fixes JB#28668) #45

Closed thp closed 9 years ago

thp commented 9 years ago

On some installations (e.g. tablet), Terminal::keyPress() messes up the keycode by converting the keypress into a Latin1 character and then appending this Latin1 character to a QString. For some reason, we were lucky so far and it worked on the phone.

Behavior change: This now causes key combinations with Ctrl to be ignored if the key isn't in the ASCII ranges 0x41-0x5f, 0x61-0x7f.

pvuorela commented 9 years ago

It appears to me the problem isn't Latin1 conversion per se, after all it should be a subset of unicode, but rather QString::append() handling char type wrong. Seems char is signed and then append has an implicit QChar conversion with negative value being converted into larger data type with prepended 1 bits.

But as this now uses append(char) only for guaranteed 7 bit values, it should be safe to go. LGTM.