Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 312795

Summary: Accessible Relations should only be added once
Product: [Eclipse Project] Platform Reporter: Carolyn MacLeod <carolynmacleod4>
Component: SWTAssignee: Carolyn MacLeod <carolynmacleod4>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: Silenio_Quarti
Version: 3.6Flags: carolynmacleod4: review+
Silenio_Quarti: review+
Target Milestone: 3.6 RC1   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
patch checks containsTarget before adding relation
none
this is the correct patch
none
patch for GTK
none
patch for cocoa none

Description Carolyn MacLeod CLA 2010-05-13 10:21:55 EDT
Created attachment 168384 [details]
patch checks containsTarget before adding relation

Before adding a new relation in Accessible.addRelation, we need to check that the relation is only being added once. This came up because the first thing the UI team did was to add a Relation in response to a UI event, and the same relation was being added over and over. For context, here is the relevant piece of the UI patch:

+++ src/org/eclipse/jface/dialogs/TitleAreaDialog.java
 	private void updateMessage(String newMessage) {
+		Display display = workArea.getDisplay();
+		Control focusControl = display.getFocusControl();
+		if (focusControl != null)
+			focusControl.getAccessible().addRelation(ACC.RELATION_DESCRIBED_BY, messageLabel.getAccessible());
 		messageLabel.setText(newMessage);
+		if (focusControl != null)
+			focusControl.getAccessible().sendEvent(ACC.EVENT_DESCRIPTION_CHANGED, null);
 	}

The attached patch fixes this by checking first whether the target was already added for the relation type.
Comment 1 Carolyn MacLeod CLA 2010-05-13 10:32:20 EDT
Created attachment 168387 [details]
this is the correct patch

I attached the wrong patch previously. This one has only the fix mentioned.
Comment 2 Silenio Quarti CLA 2010-05-13 11:25:45 EDT
Created attachment 168396 [details]
patch for GTK
Comment 3 Carolyn MacLeod CLA 2010-05-13 11:49:13 EDT
Created attachment 168402 [details]
patch for cocoa
Comment 4 Silenio Quarti CLA 2010-05-13 11:51:29 EDT
Car, please review the gtk patch
Comment 5 Carolyn MacLeod CLA 2010-05-13 12:37:43 EDT
The gtk patch looks ok - I think you should probably implement hashCode as well, though. Maybe something like:
		public int hashCode () {
			return target.hashCode() ^ type;
		}

I need to test on your machine.
Comment 6 Silenio Quarti CLA 2010-05-13 12:49:26 EDT
Relation is not been added to hash tables right now. I will add hashCode() if I ever add a relation to a set/hash table.
Comment 7 Carolyn MacLeod CLA 2010-05-13 12:56:06 EDT
Windows and Mac patch are committed.
Comment 8 Carolyn MacLeod CLA 2010-05-13 12:59:31 EDT
Fixed > 20100513