summaryrefslogtreecommitdiffstats
path: root/src/plugins
diff options
context:
space:
mode:
authorFrederik Gladhorn <frederik.gladhorn@qt.io>2017-01-03 18:00:05 +0100
committerFrederik Gladhorn <frederik.gladhorn@qt.io>2017-01-05 15:17:54 +0000
commitfafdb171e0c317ee8f871dc7b504d3713d5860eb (patch)
tree5110884a2c0fe25dccf8a631c45e2eca975bddcb /src/plugins
parent47de2ef27f9d68d5c1f2f935380e1517f99c9721 (diff)
Accessibility macOS: fix parentElement
Try to return the immediate parent first, nothing else makes sense. The original code relied on the window pointer usually being nullptr, which is not reliable. Make sure to check the validity of the handle returned, since it's possible to have the platform window being nullptr. It's not quite clear to me how to end up with a null window though. Task-number: QTBUG-52304 Change-Id: Id3e70cdab980fb0a86cebbb7c10d824d8a7dd80b Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm20
1 files changed, 10 insertions, 10 deletions
diff --git a/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm b/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm
index 97bd402b73..982c98976b 100644
--- a/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm
+++ b/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm
@@ -235,19 +235,19 @@ static void convertLineOffset(QAccessibleTextInterface *text, int *line, int *of
if (!iface || !iface->isValid())
return nil;
- if (QWindow *window = iface->window()) {
- QCocoaWindow *win = static_cast<QCocoaWindow*>(window->handle());
- return qnsview_cast(win->view());
+ if (QAccessibleInterface *parent = iface->parent()) {
+ QAccessible::Id parentId = QAccessible::uniqueId(parent);
+ return [QMacAccessibilityElement elementWithId: parentId];
}
- QAccessibleInterface *parent = iface->parent();
- if (!parent) {
- qWarning() << "INVALID PARENT FOR INTERFACE: " << iface;
- return nil;
+ if (QWindow *window = iface->window()) {
+ QPlatformWindow *platformWindow = window->handle();
+ if (platformWindow) {
+ QCocoaWindow *win = static_cast<QCocoaWindow*>(platformWindow);
+ return qnsview_cast(win->view());
+ }
}
-
- QAccessible::Id parentId = QAccessible::uniqueId(parent);
- return [QMacAccessibilityElement elementWithId: parentId];
+ return nil;
}