Project: SWT
Bug 251084 NullPointerException when VoiceOver asks for position of Shell
Reported: 2008-10-16 10:19:59 | Status: resolved fixed

- load the latest SWT Cocoa from HEAD - Run org.eclipse.swt.examples.accessibility.ControlsWithAccessibleNamesExample - Turn on VoiceOver - NPE The NPE comes from this line in getPositionAttribute: Point pt = control.getParent().toDisplay(location.x, location.y); The reason is that the control in this case is a Shell, and (top level) shells do not have a parent, so control.getParent() is null. The attached patch fixes the problem, however you will note that the patch goes further and it removes the entire 'else' case. This is because when the application does not answer anything, then we need to defer entirely to Cocoa for the position, size, etc. So the attached patch fixes the "if the app does nothing, then we do nothing" case for getPositionAttribute and getSizeAttribute. I did not go through the other attributes to do the same thing, but the same logic applies - we should only answer something if the app does.

Files changed in fix:
bundles/org.eclipse.swt/Eclipse SWT Accessibility/cocoa/org/eclipse/swt/accessibility/Accessible.java