mirror of
https://github.com/JetBrains/JetBrainsRuntime.git
synced 2025-12-23 09:49:41 +01:00
JBR-5107, JBR-5114: SIGILL/OOM from Java_sun_lwawt_macosx_LWCToolkit_getKeyboardLayoutNativeId.
A theoretical fix, it should: - Catch any NSException (as it was initially expected); - Probably fix possible memory leaks (by moving the layoutId var inside autoreleasepool).
This commit is contained in:
committed by
jbrbot
parent
8dd52d64ad
commit
a16b2e46ff
@@ -181,7 +181,11 @@ final class CPlatformResponder {
|
||||
};
|
||||
|
||||
private static boolean isCyrillicKeyboardLayout() {
|
||||
return Arrays.stream(cyrillicKeyboardLayouts).anyMatch(l -> l.equals(LWCToolkit.getKeyboardLayoutId()));
|
||||
final var currentLayout = LWCToolkit.getKeyboardLayoutId();
|
||||
if ( (currentLayout == null) || currentLayout.isEmpty() ) {
|
||||
return false;
|
||||
}
|
||||
return Arrays.asList(cyrillicKeyboardLayouts).contains(currentLayout);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -891,14 +891,26 @@ Java_sun_lwawt_macosx_LWCToolkit_isEmbedded
|
||||
JNIEXPORT jstring JNICALL
|
||||
JNICALL Java_sun_lwawt_macosx_LWCToolkit_getKeyboardLayoutNativeId(JNIEnv *env, jclass cls)
|
||||
{
|
||||
__block NSString * layoutId = NULL;
|
||||
jstring result = NULL;
|
||||
|
||||
JNI_COCOA_ENTER(env);
|
||||
NSMutableString * const layoutId = [NSMutableString stringWithCapacity:0];
|
||||
if (layoutId == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
[ThreadUtilities performOnMainThreadWaiting:YES block:^(){
|
||||
TISInputSourceRef source = TISCopyCurrentKeyboardInputSource();
|
||||
layoutId = TISGetInputSourceProperty(source, kTISPropertyInputSourceID);
|
||||
NSString * const layoutIdLocal = TISGetInputSourceProperty(source, kTISPropertyInputSourceID);
|
||||
if (layoutIdLocal != NULL) {
|
||||
[layoutId appendString:layoutIdLocal];
|
||||
}
|
||||
}];
|
||||
|
||||
result = NSStringToJavaString(env, layoutId);
|
||||
JNI_COCOA_EXIT(env);
|
||||
return NSStringToJavaString(env, layoutId);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user