Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 289488 - Unexpected delayed Selection event after Table was hidden in MouseUp
Summary: Unexpected delayed Selection event after Table was hidden in MouseUp
Status: VERIFIED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 3.5.1   Edit
Hardware: PC Mac OS X
: P3 major (vote)
Target Milestone: 3.5.1   Edit
Assignee: Silenio Quarti CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on: 279103 289483
Blocks:
  Show dependency tree
 
Reported: 2009-09-15 11:34 EDT by Markus Keller CLA
Modified: 2009-09-18 04:06 EDT (History)
4 users (show)

See Also:
daniel_megert: pmc_approved+


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Markus Keller CLA 2009-09-15 11:34:49 EDT
I20090914-1800 Cocoa, was working fine in 3.5 Cocoa. Also fine in HEAD on Win.

MultipleHyperlinkPresenter activates a link twice (on MouseUp and on Selection) on Cocoa.

E.g. when I hold command and the click "Open Implementation" on println(..) here, Eclipse first jumps to the implementation and then opens the Quick Type Hierarchy (because JavaElementImplementationHyperlink.openImplementations(..) doesn't get the shared AST in the second invocation):

public class Snippet {
	public static void main(String[] args) {
		System.out.println("Hi");
	}
}

I'm not sure yet what has changed to make this happen. I first thought it was the swapped order of events (bug 289483), but that was already the case in 3.5.

The two traces:

Daemon Thread [Thread-0] (Suspended (breakpoint at line 160 in JavaElementImplementationHyperlink))	
	JavaElementImplementationHyperlink.openImplementations(IEditorPart, IRegion, IJavaElement, SelectionDispatchAction) line: 160	
	JavaElementImplementationHyperlink.open() line: 143	
	MultipleHyperlinkPresenter$LinkListInformationControl.openSelectedLink() line: 322	
	MultipleHyperlinkPresenter$LinkListInformationControl.access$1(MultipleHyperlinkPresenter$LinkListInformationControl) line: 317	
	MultipleHyperlinkPresenter$4.mouseUp(MouseEvent) line: 294	
	TypedListener.handleEvent(Event) line: 207	
	EventTable.sendEvent(Event) line: 84	
	Display.sendEvent(EventTable, Event) line: 3597	
	Table(Widget).sendEvent(Event) line: 1268	
	Table(Widget).sendEvent(int, Event, boolean) line: 1291	
	Table(Widget).sendEvent(int, Event) line: 1276	
	Table(Control).sendMouseEvent(NSEvent, int, boolean) line: 2941	
	Display.applicationSendTrackingEvent(NSEvent, Control) line: 4264	
	Display.applicationNextEventMatchingMask(int, int, int, int, int, int) line: 4245	
	Display.applicationProc(int, int, int, int, int, int) line: 4455	
	OS.objc_msgSendSuper(objc_super, int, int) line: not available [native method]	
	Table(Widget).callSuper(int, int, int) line: 203	
	Table(Widget).mouseDown(int, int, int) line: 938	
	Table(Control).mouseDown(int, int, int) line: 2168	
	Table.mouseDown(int, int, int) line: 1905	
	Display.windowProc(int, int, int) line: 4722	
	OS.objc_msgSendSuper(objc_super, int, int) line: not available [native method]	
	Shell(Widget).callSuper(int, int, int) line: 203	
	Shell(Widget).windowSendEvent(int, int, int) line: 1783	
	Shell.windowSendEvent(int, int, int) line: 1853	
	Display.windowProc(int, int, int) line: 4782	
	OS.objc_msgSendSuper(objc_super, int, int) line: not available [native method]	
	Display.applicationSendEvent(int, int, int) line: 4339	
	Display.applicationProc(int, int, int) line: 4416	
	OS.objc_msgSend(int, int, int) line: not available [native method]	
	NSApplication.sendEvent(NSEvent) line: 101	
	Display.readAndDispatch() line: 3151	
	Workbench.runEventLoop(Window$IExceptionHandler, Display) line: 2405	
	Workbench.runUI() line: 2369	
	Workbench.access$4(Workbench) line: 2221	
	Workbench$5.run() line: 500	
	Realm.runWithDefault(Realm, Runnable) line: 332	
	Workbench.createAndRunWorkbench(Display, WorkbenchAdvisor) line: 493	
	PlatformUI.createAndRunWorkbench(Display, WorkbenchAdvisor) line: 149	
	IDEApplication.start(IApplicationContext) line: 113	
	EclipseAppHandle.run(Object) line: 194	
	EclipseAppLauncher.runApplication(Object) line: 110	
	EclipseAppLauncher.start(Object) line: 79	
	EclipseStarter.run(Object) line: 367	
	EclipseStarter.run(String[], Runnable) line: 179	
	NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line: not available [native method]	
	NativeMethodAccessorImpl.invoke(Object, Object[]) line: 39	
	DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: 25	
	Method.invoke(Object, Object...) line: 592	
	Main.invokeFramework(String[], URL[]) line: 610	
	Main.basicRun(String[]) line: 565	
	Main.run(String[]) line: 1362	
	Main.main(String[]) line: 1338	


Daemon Thread [Thread-0] (Suspended (breakpoint at line 160 in JavaElementImplementationHyperlink))	
	JavaElementImplementationHyperlink.openImplementations(IEditorPart, IRegion, IJavaElement, SelectionDispatchAction) line: 160	
	JavaElementImplementationHyperlink.open() line: 143	
	MultipleHyperlinkPresenter$LinkListInformationControl.openSelectedLink() line: 322	
	MultipleHyperlinkPresenter$LinkListInformationControl.access$1(MultipleHyperlinkPresenter$LinkListInformationControl) line: 317	
	MultipleHyperlinkPresenter$3.widgetSelected(SelectionEvent) line: 278	
	TypedListener.handleEvent(Event) line: 228	
	EventTable.sendEvent(Event) line: 84	
	Display.sendEvent(EventTable, Event) line: 3597	
	Table(Widget).sendEvent(Event) line: 1268	
	Table(Widget).sendEvent(int, Event, boolean) line: 1291	
	Table(Widget).sendEvent(int, Event) line: 1276	
	Table(Widget).notifyListeners(int, Event) line: 1097	
	Display.runDeferredEvents() line: 3495	
	Display.readAndDispatch() line: 3154	
	Workbench.runEventLoop(Window$IExceptionHandler, Display) line: 2405	
	Workbench.runUI() line: 2369	
	Workbench.access$4(Workbench) line: 2221	
	Workbench$5.run() line: 500	
	Realm.runWithDefault(Realm, Runnable) line: 332	
	Workbench.createAndRunWorkbench(Display, WorkbenchAdvisor) line: 493	
	PlatformUI.createAndRunWorkbench(Display, WorkbenchAdvisor) line: 149	
	IDEApplication.start(IApplicationContext) line: 113	
	EclipseAppHandle.run(Object) line: 194	
	EclipseAppLauncher.runApplication(Object) line: 110	
	EclipseAppLauncher.start(Object) line: 79	
	EclipseStarter.run(Object) line: 367	
	EclipseStarter.run(String[], Runnable) line: 179	
	NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line: not available [native method]	
	NativeMethodAccessorImpl.invoke(Object, Object[]) line: 39	
	DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: 25	
	Method.invoke(Object, Object...) line: 592	
	Main.invokeFramework(String[], URL[]) line: 610	
	Main.basicRun(String[]) line: 565	
	Main.run(String[]) line: 1362	
	Main.main(String[]) line: 1338
Comment 1 Dani Megert CLA 2009-09-15 12:03:59 EDT
Markus, can you investigate? There's little hope to tackle this from my Windows machine.
Comment 2 Markus Keller CLA 2009-09-15 14:13:42 EDT
Moving to SWT. We're being bitten by a bad workaround for bug 279103, which is also in 3.5.1:

Launch the snippet below, click the button, then click the selected line
build:        output:
------        -------
HEAD Cocoa    mouseUp(), widgetSelected()
3.5           mouseUp()
HEAD WinXP    widgetSelected()

If you set the selection index to 0, then HEAD Cocoa also gives mouseUp() alone (looks like an off-by one problem in Table#mouseDown(..) from bug 279103).

Our code can deal with the swapped event order on Cocoa (bug 289483), but what kills us is the delayed widgetSelected() that comes through the display loop even when the originating table has already been hidden.


package org.eclipse.swt.snippets;

import org.eclipse.swt.SWT;
import org.eclipse.swt.events.*;
import org.eclipse.swt.layout.*;
import org.eclipse.swt.widgets.*;

public class SnippetTable {
	public static void main(String[] args) {
		Display display = new Display();
		final Shell shell = new Shell(display);
		shell.setLayout(new GridLayout(1, false));
		Button button= new Button(shell, SWT.PUSH);
		button.setText("Open Table");
		button.addSelectionListener(new SelectionAdapter() {
		    public void widgetSelected(SelectionEvent e) {
		        final Shell tableShell= new Shell(shell, SWT.NO_TRIM);
		        tableShell.setLayout(new GridLayout(1, false));
		        
		        Table table = new Table(tableShell, SWT.FULL_SELECTION);
		        table.setLayoutData(new GridData(GridData.FILL_BOTH));
		        
		        for (int i = 0; i < 5; i++) {
		            TableItem ti = new TableItem(table, SWT.NONE);
		            ti.setText("Item " + i);
		        }
		        table.setSelection(1); // bug does not occur with 0
		        
		        table.addMouseListener(new MouseAdapter() {
		            public void mouseUp(MouseEvent e) {
		                System.out.println("mouseUp()");
		                tableShell.setVisible(false);
		            }
		        });
		        table.addSelectionListener(new SelectionAdapter() {
		            public void widgetSelected(SelectionEvent e) {
		                System.out.println("widgetSelected()");
		                tableShell.setVisible(false);
		            }
		        });
		        tableShell.pack();
		        tableShell.open();
		    }
        });

		shell.pack();
		shell.open();
		while (!shell.isDisposed()) {
			if (!display.readAndDispatch())
				display.sleep();
		}
		display.dispose();
	}
}
Comment 3 Markus Keller CLA 2009-09-15 14:16:50 EDT
> 3.5           mouseUp()
means 3.5 Cocoa
Comment 4 Silenio Quarti CLA 2009-09-16 12:01:53 EDT
Fixed > 20090916 (3.5.1 and 3.6 M2). The fix for bug#279103 has been removed.
Comment 5 Markus Keller CLA 2009-09-17 05:48:44 EDT
Verified in I20090917-0100 (3.6 M2).
Comment 6 Markus Keller CLA 2009-09-18 04:06:20 EDT
Verified in M20090917-0800.