diff options
author | Frederik Gladhorn <frederik.gladhorn@qt.io> | 2018-11-22 13:22:34 +0100 |
---|---|---|
committer | Frederik Gladhorn <frederik.gladhorn@qt.io> | 2018-11-23 09:50:00 +0000 |
commit | bc1678c618342774be285f24c1e2995c0a0e1600 (patch) | |
tree | 915399ab50ec115631f696705826acf1a4c6f79b /src | |
parent | 736dfc3c63f7d7844d11fe4abd6bcfb1befad3cd (diff) |
macOS accessibility: fix crash for NSAccessibilityVisibleCharacterRangeAttribute
VoiceOver or other tools may query this property even when there is no text
interface. Make sure not to crash by verifying that the interface is supported.
Found while using AccessibilityInspector to verify other changes.
Change-Id: If7ee21b7616f091b71e86bab03a871ddbabe9200
Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
Diffstat (limited to 'src')
-rw-r--r-- | src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm b/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm index 03dc895ffb..a1176da33f 100644 --- a/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm +++ b/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm @@ -345,8 +345,9 @@ static void convertLineOffset(QAccessibleTextInterface *text, int *line, int *of return [NSValue valueWithRange: NSMakeRange(0, 0)]; } else if ([attribute isEqualToString:NSAccessibilityVisibleCharacterRangeAttribute]) { // FIXME This is not correct and may impact performance for big texts - return [NSValue valueWithRange: NSMakeRange(0, iface->textInterface()->characterCount())]; - + if (QAccessibleTextInterface *text = iface->textInterface()) + return [NSValue valueWithRange: NSMakeRange(0, text->characterCount())]; + return [NSValue valueWithRange: NSMakeRange(0, iface->text(QAccessible::Name).length())]; } else if ([attribute isEqualToString:NSAccessibilityInsertionPointLineNumberAttribute]) { if (QAccessibleTextInterface *text = iface->textInterface()) { int line = 0; // true for all single line edits |