diff options
author | nyamatongwe <unknown> | 2010-03-29 03:52:24 +0000 |
---|---|---|
committer | nyamatongwe <unknown> | 2010-03-29 03:52:24 +0000 |
commit | 3d29f85c78c10b46b0b3c39e36bb1e7b1aa1333f (patch) | |
tree | b7517d43f56f621a6148a4d81e5ac8236c6cb6eb | |
parent | 6bbc68fb3e49963433e710161b218c3af37cf5b4 (diff) | |
download | scintilla-mirror-3d29f85c78c10b46b0b3c39e36bb1e7b1aa1333f.tar.gz |
Ensure does not crash if NULL handle.
-rw-r--r-- | macosx/ScintillaMacOSX.cxx | 31 |
1 files changed, 17 insertions, 14 deletions
diff --git a/macosx/ScintillaMacOSX.cxx b/macosx/ScintillaMacOSX.cxx index 1ff26a2b7..2abef78c7 100644 --- a/macosx/ScintillaMacOSX.cxx +++ b/macosx/ScintillaMacOSX.cxx @@ -1830,20 +1830,23 @@ static inline UniChar GetCharacterWithoutModifiers( EventRef rawKeyboardEvent ) SInt16 lastKeyLayoutID = GetScriptVariable( /*currentKeyScript*/ GetScriptManagerVariable(smKeyScript), smScriptKeys); Handle uchrHandle = GetResource('uchr', lastKeyLayoutID); - // Translate the key press ignoring ctrl and option - UInt32 ignoredDeadKeys = 0; - UInt32 ignoredActualLength = 0; - UniChar unicodeKey = 0; - // (((modifiers & shiftKey) >> 8) & 0xFF) - OSStatus err; - err = UCKeyTranslate( reinterpret_cast<UCKeyboardLayout*>( *uchrHandle ), keyCode, kUCKeyActionDown, - /* modifierKeyState */ 0, LMGetKbdType(), kUCKeyTranslateNoDeadKeysMask, &ignoredDeadKeys, - /* buffer length */ 1, - /* actual length */ &ignoredActualLength, - /* string */ &unicodeKey ); - assert( err == noErr ); - - return unicodeKey; + if (uchrHandle) { + // Translate the key press ignoring ctrl and option + UInt32 ignoredDeadKeys = 0; + UInt32 ignoredActualLength = 0; + UniChar unicodeKey = 0; + // (((modifiers & shiftKey) >> 8) & 0xFF) + OSStatus err; + err = UCKeyTranslate( reinterpret_cast<UCKeyboardLayout*>( *uchrHandle ), keyCode, kUCKeyActionDown, + /* modifierKeyState */ 0, LMGetKbdType(), kUCKeyTranslateNoDeadKeysMask, &ignoredDeadKeys, + /* buffer length */ 1, + /* actual length */ &ignoredActualLength, + /* string */ &unicodeKey ); + assert( err == noErr ); + + return unicodeKey; + } + return 0; } // Text input is very annoying: |