Skip to content

Commit d948d3f

Browse files
John WoodSiegeLord
authored andcommitted
Fix sig 11 crash when using a Japanese (or possibly other CJK type) keyboard
Clues for the fix found here: microsoft/vscode#23833
1 parent 7eb2e71 commit d948d3f

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/macosx/keybd.m

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,14 @@ void _al_osx_keyboard_handler(int pressed, NSEvent *event, ALLEGRO_DISPLAY* dpy)
277277
/* https://stackoverflow.com/a/22677690 */
278278
TISInputSourceRef keyboard_input = TISCopyCurrentKeyboardInputSource();
279279
CFDataRef layout_data = TISGetInputSourceProperty(keyboard_input, kTISPropertyUnicodeKeyLayoutData);
280+
/* https://github.com/microsoft/vscode/issues/23833 */
281+
if (!layout_data) {
282+
/* TISGetInputSourceProperty returns null with a Japanese keyboard layout.
283+
* Using TISCopyCurrentKeyboardLayoutInputSource to fix the NULL return.
284+
*/
285+
keyboard_input = TISCopyCurrentKeyboardLayoutInputSource();
286+
layout_data = TISGetInputSourceProperty(keyboard_input, kTISPropertyUnicodeKeyLayoutData);
287+
}
280288
const UCKeyboardLayout *layout = (const UCKeyboardLayout *)CFDataGetBytePtr(layout_data);
281289

282290
CGEventFlags modifier_flags = [event modifierFlags];

0 commit comments

Comments
 (0)