| Summary: | [Compatibility] [DND] hitting ESC caused an NPE | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| Product: | [Eclipse Project] Platform | Reporter: | Paul Webster <pwebster> | ||||||||
| Component: | UI | Assignee: | Platform UI Triaged <platform-ui-triaged> | ||||||||
| Status: | RESOLVED WORKSFORME | QA Contact: | Eric Moffatt <emoffatt> | ||||||||
| Severity: | normal | ||||||||||
| Priority: | P3 | CC: | emoffatt, Lars.Vogel, pinnamur, Udo.Walker | ||||||||
| Version: | 4.1 | ||||||||||
| Target Milestone: | --- | ||||||||||
| Hardware: | PC | ||||||||||
| OS: | Linux | ||||||||||
| Whiteboard: | |||||||||||
| Attachments: |
|
||||||||||
|
Description
Paul Webster
I can investigate this problem. Created attachment 190856 [details]
Proposed patch for Windows
While trying to reproduce this on Windows, I encountered different NPE stack when a view is dropped and Esc key is pressed immediately.
-------------------
java.lang.NullPointerException
at org.eclipse.e4.ui.workbench.addons.dndaddon.DnDManager.finishDrag(DnDManager.java:261)
at org.eclipse.e4.ui.workbench.addons.dndaddon.DnDManager.startDrag(DnDManager.java:233)
at org.eclipse.e4.ui.workbench.addons.dndaddon.DnDManager$3.handleEvent(DnDManager.java:110)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
at org.eclipse.swt.widgets.Display.filterEvent(Display.java:1262)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1052)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4126)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3715)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$7.run(PartRenderingEngine.java:842)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:758)
at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:87)
-------------------
We have 2 events here - view is dropped, and Esc key is pressed.
After the 1st event, SplitDropAgent accepts the drop and calls for dndManager.update() while docking the view.
Due to the above update call, it tries to process the pending Esc key on tracker and thus, it set the dragAgent to null after it finishes the drag.
Thus, the remaining 1st event encounters NPE due to the null value of dragAgent.
The fix is to remove the keyFilter after the tracker is dropped/opened. Add the filter back after we perform the dragFinish. The attached patch contain these changes to fix this problem.
Created attachment 191016 [details]
Slight revision to your patch
Praveen, welcome !! and thanks for the patch...
Here's a minor revision based on the idea that the ESC listener is not necessary unless we're in the dragging loop.
What do you think ?
Note that either fix is better than what's there I think but we're going to be reviewing this post-M6. Right now we're breaking the API contract with the SWT Tracker by spinning the event loop while the tracker is open (almost certainly the cause of Paul's issue). It spins a specialized event loop and will capture ESC and return false but we've already eaten the char in our listener. We should either stop using the tracker or stop spinning the event loop... Created attachment 191297 [details]
Patch for Linux
In Linux, tracker has its own event loop to process the events based on it. Due to this, Esc key is processed by tracker and then it is disposed. The existing mouseMoveListener unaware of this, tries to finish the processing of the existing drag event and then, hits with NPE.
The proposed fix is to check null for tracker after tracker.open is returned.
I am using direct editing of text within the GEF framework under Eclipse 3.6.1. I got a NPE here: java.lang.NullPointerException at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1271) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1263) at org.eclipse.swt.widgets.Control.setBounds(Control.java:881) at org.eclipse.swt.widgets.Control.setSize(Control.java:1065) I get this only under Linux. Under Windows it works fine. WORKSFORME in Luna. Please reopen if you still see this issue. |