Bug 96492 - Inconsistent listener notification
Summary: Inconsistent listener notification
Status: NEW
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 3.1   Edit
Hardware: PC Windows XP
: P3 normal with 1 vote (vote)
Target Milestone: ---   Edit
Assignee: Steve Northover CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-05-24 14:51 EDT by Randy Hudson CLA
Modified: 2019-09-06 15:32 EDT (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Randy Hudson CLA 2005-05-24 14:51:20 EDT
If a listener removes itself and re-adds itself during an event callback,
sometimes it will receive an additional notification. Specifically, in the
presence of other listeners, it gets duplicate notification.  If it is the sole
listener, it only gets notified once.  The following snippet demonstrates the
problem.  If two listeners are used, there is an infinite loop.

public static void main(String[] args) {
	Display display = new Display();
	Shell shell = new Shell(display);

	final Text text = new Text(shell, SWT.NONE);

	text.setBounds(10, 10, 90, 30);
	text.setText("blah");
	
	class Hooked implements ModifyListener {
		public void modifyText(ModifyEvent e) {
			text.removeModifyListener(this);
			text.addModifyListener(this);
		}
	};
	
//	text.addModifyListener(new Hooked());
	text.addModifyListener(new Hooked());
	
	shell.open();
	while (!shell.isDisposed()) {
		if (!display.readAndDispatch())
			display.sleep();
	}
}
Comment 1 Randy Hudson CLA 2005-06-03 14:16:29 EDT
Silenio, was this fixed by your new compression technique?
Comment 2 Steve Northover CLA 2005-06-03 16:04:41 EDT
No.
Comment 3 Andreas Kozma CLA 2007-04-23 07:19:24 EDT
(In reply to comment #2)
> No.

In addition, the AbstractCombo.removeModifyListener(ModifyListener) method. line 2 reads: if(text != null) text.addModifyListener(listener);

I guess this should be:
if(text != null) text.removeModifyListener(listener);

Fixing this, didn't solve the above problem, however. Using the untyped listener with SWT.modify reproduced the same behavior as outlined in the original description.

Comment 4 Steve Northover CLA 2007-04-23 18:09:04 EDT
AbstractCombo is not an SWT class.  Does it belong to GEF?
Comment 5 Randy Hudson CLA 2007-04-24 11:50:29 EDT
Maybe he meant CCombo?
Comment 6 Eclipse Webmaster CLA 2019-09-06 15:32:06 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.