|
9 | 9 | #import <objc/message.h> |
10 | 10 |
|
11 | 11 | #include "flutter/common/constants.h" |
12 | | -#include "flutter/shell/platform/embedder/embedder.h" |
13 | | - |
| 12 | +#include "flutter/fml/platform/darwin/cf_utils.h" |
14 | 13 | #import "flutter/shell/platform/darwin/common/framework/Headers/FlutterChannels.h" |
15 | 14 | #import "flutter/shell/platform/darwin/common/framework/Headers/FlutterCodecs.h" |
16 | 15 | #import "flutter/shell/platform/darwin/macos/framework/Headers/FlutterEngine.h" |
|
20 | 19 | #import "flutter/shell/platform/darwin/macos/framework/Source/FlutterRenderer.h" |
21 | 20 | #import "flutter/shell/platform/darwin/macos/framework/Source/FlutterTextInputSemanticsObject.h" |
22 | 21 | #import "flutter/shell/platform/darwin/macos/framework/Source/FlutterView.h" |
| 22 | +#include "flutter/shell/platform/embedder/embedder.h" |
23 | 23 |
|
24 | 24 | #pragma mark - Static types and data. |
25 | 25 |
|
@@ -902,17 +902,16 @@ - (NSObject*)valuePublishedByPlugin:(NSString*)pluginKey { |
902 | 902 | * It's returned in NSData* to enable auto reference count. |
903 | 903 | */ |
904 | 904 | static NSData* CurrentKeyboardLayoutData() { |
905 | | - TISInputSourceRef source = TISCopyCurrentKeyboardInputSource(); |
| 905 | + fml::CFRef<TISInputSourceRef> source(TISCopyCurrentKeyboardInputSource()); |
906 | 906 | CFTypeRef layout_data = TISGetInputSourceProperty(source, kTISPropertyUnicodeKeyLayoutData); |
907 | 907 | if (layout_data == nil) { |
908 | | - CFRelease(source); |
909 | 908 | // TISGetInputSourceProperty returns null with Japanese keyboard layout. |
910 | 909 | // Using TISCopyCurrentKeyboardLayoutInputSource to fix NULL return. |
911 | 910 | // https://github.com/microsoft/node-native-keymap/blob/5f0699ded00179410a14c0e1b0e089fe4df8e130/src/keyboard_mac.mm#L91 |
912 | | - source = TISCopyCurrentKeyboardLayoutInputSource(); |
| 911 | + source.Reset(TISCopyCurrentKeyboardLayoutInputSource()); |
913 | 912 | layout_data = TISGetInputSourceProperty(source, kTISPropertyUnicodeKeyLayoutData); |
914 | 913 | } |
915 | | - return (__bridge_transfer NSData*)CFRetain(layout_data); |
| 914 | + return (__bridge NSData*)layout_data; |
916 | 915 | } |
917 | 916 |
|
918 | 917 | - (void)sendKeyEvent:(const FlutterKeyEvent&)event |
|
0 commit comments