Community
Participate
Working Groups
We get one old call and then the new correct call. We need to understand why. From bug 342917 comment #8 Here is the stack trace for when the selection gets updated to the wrong element: java.lang.Throwable at java.lang.Thread.dumpStack(Thread.java:417) at org.eclipse.ui.internal.WorkbenchPage.updateShowInSources(WorkbenchPage.java:373) at org.eclipse.ui.internal.e4.compatibility.SelectionService$1.selectionChanged(SelectionService.java:76) at org.eclipse.e4.ui.internal.workbench.SelectionServiceImpl.notifyListeners(SelectionServiceImpl.java:123) at org.eclipse.e4.ui.internal.workbench.SelectionServiceImpl.access$3(SelectionServiceImpl.java:119) at org.eclipse.e4.ui.internal.workbench.SelectionServiceImpl$2.changed(SelectionServiceImpl.java:157) at org.eclipse.e4.core.internal.contexts.TrackableComputationExt.update(TrackableComputationExt.java:91) at org.eclipse.e4.core.internal.contexts.EclipseContext.processScheduled(EclipseContext.java:326) at org.eclipse.e4.core.internal.contexts.EclipseContext.set(EclipseContext.java:343) at org.eclipse.e4.ui.internal.workbench.PartSelectionServiceImpl.setSelection(PartSelectionServiceImpl.java:66) at org.eclipse.ui.internal.e4.compatibility.SelectionService.selectionChanged(SelectionService.java:319) at org.eclipse.jface.viewers.Viewer$2.run(Viewer.java:164) at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42) at org.eclipse.ui.internal.JFaceUtil$1.run(JFaceUtil.java:49) at org.eclipse.jface.util.SafeRunnable.run(SafeRunnable.java:175) at org.eclipse.jface.viewers.Viewer.fireSelectionChanged(Viewer.java:162) at org.eclipse.jface.text.TextViewer.fireSelectionChanged(TextViewer.java:2732) at org.eclipse.jface.text.TextViewer.selectionChanged(TextViewer.java:2711) at org.eclipse.jface.text.TextViewer$4.widgetSelected(TextViewer.java:1830) at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:240) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1053) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1077) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1062) at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:774) at org.eclipse.swt.custom.StyledText.sendSelectionEvent(StyledText.java:8033) at org.eclipse.swt.custom.StyledText.clearSelection(StyledText.java:1710) at org.eclipse.swt.custom.StyledText.doMouseLocationChange(StyledText.java:2811) at org.eclipse.swt.custom.StyledText.handleMouseDown(StyledText.java:6000) at org.eclipse.swt.custom.StyledText$7.handleEvent(StyledText.java:5635) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1053) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4150) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3739) at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$7.run(PartRenderingEngine.java:873) at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332) at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:789) at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:87) at org.eclipse.ui.internal.Workbench$3.run(Workbench.java:542) at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:522) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149) at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:123) at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196) at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110) at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:344) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:60) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37) at java.lang.reflect.Method.invoke(Method.java:611) at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:622) at org.eclipse.equinox.launcher.Main.basicRun(Main.java:577) at org.eclipse.equinox.launcher.Main.run(Main.java:1410) at org.eclipse.equinox.launcher.Main.main(Main.java:1386) Then it gets called again about a second later with the correct selection: java.lang.Throwable at java.lang.Thread.dumpStack(Thread.java:417) at org.eclipse.ui.internal.WorkbenchPage.updateShowInSources(WorkbenchPage.java:373) at org.eclipse.ui.internal.e4.compatibility.SelectionService$1.selectionChanged(SelectionService.java:76) at org.eclipse.e4.ui.internal.workbench.SelectionServiceImpl.notifyListeners(SelectionServiceImpl.java:123) at org.eclipse.e4.ui.internal.workbench.SelectionServiceImpl.access$3(SelectionServiceImpl.java:119) at org.eclipse.e4.ui.internal.workbench.SelectionServiceImpl$2.changed(SelectionServiceImpl.java:157) at org.eclipse.e4.core.internal.contexts.TrackableComputationExt.update(TrackableComputationExt.java:91) at org.eclipse.e4.core.internal.contexts.EclipseContext.processScheduled(EclipseContext.java:326) at org.eclipse.e4.core.internal.contexts.EclipseContext.set(EclipseContext.java:343) at org.eclipse.e4.ui.internal.workbench.PartSelectionServiceImpl.setSelection(PartSelectionServiceImpl.java:66) at org.eclipse.ui.internal.e4.compatibility.SelectionService.selectionChanged(SelectionService.java:319) at org.eclipse.jface.text.TextViewer.firePostSelectionChanged(TextViewer.java:2749) at org.eclipse.jface.text.TextViewer.firePostSelectionChanged(TextViewer.java:2697) at org.eclipse.jface.text.TextViewer$5.run(TextViewer.java:2676) at org.eclipse.swt.widgets.Display.runTimer(Display.java:4251) at org.eclipse.swt.widgets.Display.messageProc(Display.java:3338) at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method) at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java:2525) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3737) at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$7.run(PartRenderingEngine.java:873) at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332) at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:789) at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:87) at org.eclipse.ui.internal.Workbench$3.run(Workbench.java:542) at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:522) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149) at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:123) at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196) at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110) at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:344) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:60) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37) at java.lang.reflect.Method.invoke(Method.java:611) at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:622) at org.eclipse.equinox.launcher.Main.basicRun(Main.java:577) at org.eclipse.equinox.launcher.Main.run(Main.java:1410) at org.eclipse.equinox.launcher.Main.main(Main.java:1386)
I can't induce the same stack trace (presumably because of the changes that's been in this code) but I do get the same behaviour. The reason there are two selection events is because the first one is fired for when the control gets activated by the mouse click. At this point in time, the selection has not yet been changed to the new selection so an event is fired for the original selection. UI processing continues and then the mouse click is registered with the control in question and the new selection occurs which triggers the second selection event (with the "correct" new selection). With that in mind, this behaviour is correct and in line with what happens in 3.x. Resolving as INVALID.