changeset 7801:e68dd7128fdd

RT-38187: [a11y] Intermittent NPE running HelloSanity or SceneBuilder with Narrator Remove possible NPE in GetSelection()
author Felipe Heidrich <felipe.heidrich@oracle.com>
date Tue, 26 Aug 2014 13:49:26 -0700
parents 6feed77a2bfa
children 96b05e9b6bd4
files modules/graphics/src/main/java/com/sun/glass/ui/win/WinAccessible.java
diffstat 1 files changed, 6 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/modules/graphics/src/main/java/com/sun/glass/ui/win/WinAccessible.java	Tue Aug 26 12:58:58 2014 -0700
+++ b/modules/graphics/src/main/java/com/sun/glass/ui/win/WinAccessible.java	Tue Aug 26 13:49:26 2014 -0700
@@ -1117,6 +1117,7 @@
          * Check the role before processing message.
          */
         AccessibleRole role = (AccessibleRole)getAttribute(ROLE);
+        if (role == null) return null;
         switch (role) {
             case TREE_TABLE_VIEW:
             case TABLE_VIEW:
@@ -1143,14 +1144,16 @@
                     selectionRange = new WinTextRangeProvider(this);
                 }
                 if (!selectionRangeValid) {
-                    int start = (Integer)getAttribute(SELECTION_START);
+                    Integer result = (Integer)getAttribute(SELECTION_START);
+                    int start = result != null ? result : 0;
                     int end = -1;
                     int length = -1;
                     if (start >= 0) {
-                        end = (Integer)getAttribute(SELECTION_END);
+                        result = (Integer)getAttribute(SELECTION_END);
+                        end = result != null ? result : 0;
                         if (end >= start) {
                             String string = (String)getAttribute(TEXT);
-                            length = string.length();
+                            length = string != null ? string.length() : 0;
                         }
                     }
                     if (length != -1 && end <= length) {