mirror of
https://github.com/keymanapp/keyman.git
synced 2026-08-05 00:15:32 +00:00
fix(mac): correct memory width mismatch in keyCodeForChar
This commit is contained in:
parent
82a1a0ffc7
commit
5b3aecc1f8
1 changed files with 14 additions and 9 deletions
|
|
@ -470,7 +470,6 @@ CFStringRef createStringForKey(CGKeyCode keyCode)
|
|||
CGKeyCode keyCodeForChar(const char c)
|
||||
{
|
||||
static CFMutableDictionaryRef charToCodeDict = NULL;
|
||||
CGKeyCode code;
|
||||
UniChar character = c;
|
||||
CFStringRef charStr = NULL;
|
||||
|
||||
|
|
@ -495,9 +494,15 @@ CGKeyCode keyCodeForChar(const char c)
|
|||
|
||||
charStr = CFStringCreateWithCharacters(kCFAllocatorDefault, &character, 1);
|
||||
|
||||
/* Our values may be NULL (0), so we need to use this function. */
|
||||
if (!CFDictionaryGetValueIfPresent(charToCodeDict, charStr,
|
||||
(const void **)&code)) {
|
||||
/* Our values may be NULL (0), so we need to use this function.
|
||||
* Use a pointer-sized variable to receive the value, since CFDictionary
|
||||
* stores values as void pointers (64-bit on modern systems), then cast
|
||||
* to CGKeyCode (uint16_t). */
|
||||
const void *value = NULL;
|
||||
CGKeyCode code;
|
||||
if (CFDictionaryGetValueIfPresent(charToCodeDict, charStr, &value)) {
|
||||
code = (CGKeyCode)(uintptr_t)value;
|
||||
} else {
|
||||
code = UINT16_MAX;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue