Skip to content

Commit f735d67

Browse files
committed
fixed NULL return for Japanese keyboard layout
1 parent 76f2076 commit f735d67

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/keyboard_mac.mm

+9-3
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,15 @@ void _GetKeyMap(const FunctionCallbackInfo<Value>& args) {
106106
TISInputSourceRef source = TISCopyCurrentKeyboardInputSource();
107107
CFDataRef layout_data = static_cast<CFDataRef>((TISGetInputSourceProperty(source, kTISPropertyUnicodeKeyLayoutData)));
108108
if (!layout_data) {
109-
// https://developer.apple.com/library/mac/documentation/TextFonts/Reference/TextInputSourcesReference/#//apple_ref/c/func/TISGetInputSourceProperty
110-
args.GetReturnValue().Set(result);
111-
return;
109+
// TISGetInputSourceProperty returns null with Japanese keyboard layout.
110+
// Using TISCopyCurrentKeyboardLayoutInputSource to fix NULL return.
111+
source = TISCopyCurrentKeyboardLayoutInputSource();
112+
layout_data = static_cast<CFDataRef>((TISGetInputSourceProperty(source, kTISPropertyUnicodeKeyLayoutData)));
113+
if (!layout_data) {
114+
// https://developer.apple.com/library/mac/documentation/TextFonts/Reference/TextInputSourcesReference/#//apple_ref/c/func/TISGetInputSourceProperty
115+
args.GetReturnValue().Set(result);
116+
return;
117+
}
112118
}
113119

114120
const UCKeyboardLayout* keyboardLayout = reinterpret_cast<const UCKeyboardLayout*>(CFDataGetBytePtr(layout_data));

0 commit comments

Comments
 (0)