Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLev Ufimtsev2016-08-09 15:46:54 +0000
committerArun Thondapu2016-11-16 08:25:36 +0000
commit83d34538078cfcb43e1bd9344d645859ecc8e2ae (patch)
treecc5d69b39f81b8a3775b2b6da42e162cb8f52989
parentd9bedc950dba514b4a1bc3836fac1ab182e2e09a (diff)
downloadeclipse.platform.swt-83d34538078cfcb43e1bd9344d645859ecc8e2ae.tar.gz
eclipse.platform.swt-83d34538078cfcb43e1bd9344d645859ecc8e2ae.tar.xz
eclipse.platform.swt-83d34538078cfcb43e1bd9344d645859ecc8e2ae.zip
Bug 312451: Accessible.addRelations should check if target == null
Adding null checks around public api that will throw an error if given a null object. This should at least tell us why null objects are created in the first place. Note, this is a slight api change, the public api now throws an exception. Change-Id: I4f526ce1af208cecc2c9f34adb69105d5dcb8503 Task-Url: https://bugs.eclipse.org/bugs/show_bug.cgi?id=312451 Signed-off-by: Lev Ufimtsev <lufimtse@redhat.com> Bug 312451: Accessible.addRelations should check if target == null Change-Id: Ib226bab92c0abfc47fc29fc500aafb028107827c Bug 312451: Accessible.addRelations should check if target == null Adding null check to 'removeRelation' Change-Id: Iffcc38e1bb4372dd6fd9b794a2677aff16b7dca2 Task-Url: https://bugs.eclipse.org/bugs/show_bug.cgi?id=312451 Signed-off-by: Leo Ufimtsev <lufimtse@redhat.com>
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT Accessibility/cocoa/org/eclipse/swt/accessibility/Accessible.java6
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT Accessibility/gtk/org/eclipse/swt/accessibility/Accessible.java5
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT Accessibility/gtk/org/eclipse/swt/accessibility/AccessibleObject.java26
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT Accessibility/win32/org/eclipse/swt/accessibility/Accessible.java6
4 files changed, 37 insertions, 6 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Accessibility/cocoa/org/eclipse/swt/accessibility/Accessible.java b/bundles/org.eclipse.swt/Eclipse SWT Accessibility/cocoa/org/eclipse/swt/accessibility/Accessible.java
index 1e064353d0..3327c593be 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT Accessibility/cocoa/org/eclipse/swt/accessibility/Accessible.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Accessibility/cocoa/org/eclipse/swt/accessibility/Accessible.java
@@ -455,11 +455,13 @@ public class Accessible {
*
* @param type an <code>ACC</code> constant beginning with RELATION_* indicating the type of relation
* @param target the accessible that is the target for this relation
+ * @exception IllegalArgumentException ERROR_NULL_ARGUMENT - if the Accessible target is null
*
* @since 3.6
*/
public void addRelation(int type, Accessible target) {
checkWidget();
+ if (target == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
if (relations[type] == null) {
relations[type] = new Relation(this, type);
}
@@ -3080,11 +3082,13 @@ public class Accessible {
*
* @param type an <code>ACC</code> constant beginning with RELATION_* indicating the type of relation
* @param target the accessible that is the target for this relation
- *
+ * @exception IllegalArgumentException ERROR_NULL_ARGUMENT - if the Accessible target is null
+ *
* @since 3.6
*/
public void removeRelation(int type, Accessible target) {
checkWidget();
+ if (target == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
if (relations[type] != null) {
relations[type].removeTarget(target);
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Accessibility/gtk/org/eclipse/swt/accessibility/Accessible.java b/bundles/org.eclipse.swt/Eclipse SWT Accessibility/gtk/org/eclipse/swt/accessibility/Accessible.java
index 018fd36a5d..af6b3c5511 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT Accessibility/gtk/org/eclipse/swt/accessibility/Accessible.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Accessibility/gtk/org/eclipse/swt/accessibility/Accessible.java
@@ -412,10 +412,12 @@ public class Accessible {
* @param type an <code>ACC</code> constant beginning with RELATION_* indicating the type of relation
* @param target the accessible that is the target for this relation
*
+ * @exception IllegalArgumentException ERROR_NULL_ARGUMENT - if the Accessible target is null
* @since 3.6
*/
public void addRelation(int type, Accessible target) {
checkWidget();
+ if (target == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
if (relations == null) relations = new ArrayList<>();
Relation relation = new Relation(type, target);
if (relations.indexOf(relation) != -1) return;
@@ -867,12 +869,13 @@ public class Accessible {
*
* @param type an <code>ACC</code> constant beginning with RELATION_* indicating the type of relation
* @param target the accessible that is the target for this relation
- *
+ * @exception IllegalArgumentException ERROR_NULL_ARGUMENT - if the Accessible target is null
* @since 3.6
*/
public void removeRelation(int type, Accessible target) {
checkWidget();
if (relations == null) return;
+ if (target == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
Relation relation = new Relation(type, target);
int index = relations.indexOf(relation);
if (index == -1) return;
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Accessibility/gtk/org/eclipse/swt/accessibility/AccessibleObject.java b/bundles/org.eclipse.swt/Eclipse SWT Accessibility/gtk/org/eclipse/swt/accessibility/AccessibleObject.java
index 0f24f24680..7ab4014920 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT Accessibility/gtk/org/eclipse/swt/accessibility/AccessibleObject.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Accessibility/gtk/org/eclipse/swt/accessibility/AccessibleObject.java
@@ -3577,7 +3577,18 @@ class AccessibleObject {
}
void addRelation (int type, Accessible target) {
- OS.atk_object_add_relationship(handle, toATKRelation(type), target.getAccessibleObject().handle);
+ AccessibleObject targetAccessibleObject = target.getAccessibleObject();
+ if (targetAccessibleObject != null) {
+ /*
+ * FIXME: Workaround for https://bugs.eclipse.org/312451
+ *
+ * This null check is conceptually wrong and will probably cause
+ * inconsistent behavior, but since we don't know in what
+ * circumstances the target doesn't have an accessibleObject, that's
+ * the best way we know to avoid throwing an NPE.
+ */
+ OS.atk_object_add_relationship(handle, toATKRelation(type), targetAccessibleObject.handle);
+ }
}
void release () {
@@ -3597,7 +3608,18 @@ class AccessibleObject {
}
void removeRelation (int type, Accessible target) {
- OS.atk_object_remove_relationship (handle, toATKRelation(type), target.getAccessibleObject().handle);
+ AccessibleObject targetAccessibleObject = target.getAccessibleObject();
+ if (targetAccessibleObject != null) {
+ /*
+ * FIXME: Workaround for https://bugs.eclipse.org/312451
+ *
+ * This null check is conceptually wrong and will probably cause
+ * inconsistent behavior, but since we don't know in what
+ * circumstances the target doesn't have an accessibleObject, that's
+ * the best way we know to avoid throwing an NPE.
+ */
+ OS.atk_object_remove_relationship (handle, toATKRelation(type), targetAccessibleObject.handle);
+ }
}
void selectionChanged () {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Accessibility/win32/org/eclipse/swt/accessibility/Accessible.java b/bundles/org.eclipse.swt/Eclipse SWT Accessibility/win32/org/eclipse/swt/accessibility/Accessible.java
index 6c21767786..406182cb40 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT Accessibility/win32/org/eclipse/swt/accessibility/Accessible.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Accessibility/win32/org/eclipse/swt/accessibility/Accessible.java
@@ -1039,11 +1039,12 @@ public class Accessible {
*
* @param type an <code>ACC</code> constant beginning with RELATION_* indicating the type of relation
* @param target the accessible that is the target for this relation
- *
+ * @exception IllegalArgumentException ERROR_NULL_ARGUMENT - if the Accessible target is null
* @since 3.6
*/
public void addRelation(int type, Accessible target) {
checkWidget();
+ if (target == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
if (relations[type] == null) {
relations[type] = new Relation(this, type);
}
@@ -1447,11 +1448,12 @@ public class Accessible {
*
* @param type an <code>ACC</code> constant beginning with RELATION_* indicating the type of relation
* @param target the accessible that is the target for this relation
- *
+ * @exception IllegalArgumentException ERROR_NULL_ARGUMENT - if the Accessible target is null
* @since 3.6
*/
public void removeRelation(int type, Accessible target) {
checkWidget();
+ if (target == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
Relation relation = relations[type];
if (relation != null) {
relation.removeTarget(target);

Back to the top