diff options
author | Prasanth Ullattil <prasanth.ullattil@nokia.com> | 2010-08-03 12:49:28 (GMT) |
---|---|---|
committer | Prasanth Ullattil <prasanth.ullattil@nokia.com> | 2010-08-03 12:55:18 (GMT) |
commit | 307601da8d3b64de7b7d83a6de0b5dac290b0eb6 (patch) | |
tree | c4ae0b701cc7723d842888b24a45265a0c38c472 /src/gui/kernel/qt_cocoa_helpers_mac.mm | |
parent | 99a6ff848dd90a896a8f8b58379bcc37c5733566 (diff) | |
download | Qt-307601da8d3b64de7b7d83a6de0b5dac290b0eb6.zip Qt-307601da8d3b64de7b7d83a6de0b5dac290b0eb6.tar.gz Qt-307601da8d3b64de7b7d83a6de0b5dac290b0eb6.tar.bz2 |
Crash when pressing the '£' key on Belgian Keyboard layout (Cocoa)
In some cases the NSKeyDown event won't have fully constructed string
in the [NSEvent characters]. So we need to add a guard before accessing
the elements of this NSString.
Task-number: QTBUG-12474
Reviewed-by: Richard Moe Gustavsen
Diffstat (limited to 'src/gui/kernel/qt_cocoa_helpers_mac.mm')
-rw-r--r-- | src/gui/kernel/qt_cocoa_helpers_mac.mm | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/gui/kernel/qt_cocoa_helpers_mac.mm b/src/gui/kernel/qt_cocoa_helpers_mac.mm index 647cb86..7d23abf 100644 --- a/src/gui/kernel/qt_cocoa_helpers_mac.mm +++ b/src/gui/kernel/qt_cocoa_helpers_mac.mm @@ -685,9 +685,11 @@ bool qt_dispatchKeyEvent(void * /*NSEvent * */ keyEvent, QWidget *widgetToGetEve unsigned int info = 0; if ([event type] == NSKeyDown) { NSString *characters = [event characters]; - unichar value = [characters characterAtIndex:0]; - qt_keymapper_private()->updateKeyMap(0, key_event, (void *)&value); - info = value; + if ([characters length]) { + unichar value = [characters characterAtIndex:0]; + qt_keymapper_private()->updateKeyMap(0, key_event, (void *)&value); + info = value; + } } // Redirect keys to alien widgets. |