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

Bug 325480

Summary: CleanupAddon seems to be causing problems with multi-instance editors
Product: [Eclipse Project] e4 Reporter: Remy Suen <remy.suen>
Component: UIAssignee: Project Inbox <e4.ui-inbox>
Status: RESOLVED WORKSFORME QA Contact:
Severity: major    
Priority: P3 CC: Lars.Vogel
Version: 1.0   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description Remy Suen CLA 2010-09-16 11:12:17 EDT
1. Open a file.
2. Window > New Editor
3. Drag the second one to the right so you now have two separate editor stacks.
4. Activate the original editor.
5. Ctrl+W

java.lang.NullPointerException
	at java.io.StringReader.<init>(StringReader.java:54)
	at org.eclipse.ui.internal.EditorReference.<init>(EditorReference.java:65)
	at org.eclipse.ui.internal.Workbench.createEditorReference(Workbench.java:1702)
	at org.eclipse.ui.internal.Workbench.setReference(Workbench.java:1685)
	at org.eclipse.ui.internal.Workbench.access$18(Workbench.java:1672)
	at org.eclipse.ui.internal.Workbench$30.handleEvent(Workbench.java:1623)
	at org.eclipse.e4.ui.services.internal.events.UIEventHandler.handleEvent(UIEventHandler.java:41)
	at org.eclipse.equinox.internal.event.EventHandlerWrapper.handleEvent(EventHandlerWrapper.java:188)
	at org.eclipse.equinox.internal.event.EventHandlerTracker.dispatchEvent(EventHandlerTracker.java:198)
	at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230)
	at org.eclipse.osgi.framework.eventmgr.ListenerQueue.dispatchEventSynchronous(ListenerQueue.java:148)
	at org.eclipse.equinox.internal.event.EventAdminImpl.dispatchEvent(EventAdminImpl.java:139)
	at org.eclipse.equinox.internal.event.EventAdminImpl.sendEvent(EventAdminImpl.java:78)
	at org.eclipse.equinox.internal.event.EventComponent.sendEvent(EventComponent.java:39)
	at org.eclipse.e4.ui.services.internal.events.EventBroker.send(EventBroker.java:73)
	at org.eclipse.e4.ui.internal.workbench.UIEventPublisher.notifyChanged(UIEventPublisher.java:58)
	at org.eclipse.emf.common.notify.impl.BasicNotifierImpl.eNotify(BasicNotifierImpl.java:380)
	at org.eclipse.e4.ui.model.application.ui.basic.impl.PartImpl.setContext(PartImpl.java:444)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.createGui(PartRenderingEngine.java:393)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.createGui(PartRenderingEngine.java:490)
	at org.eclipse.e4.ui.workbench.renderers.swt.StackRenderer.showTab(StackRenderer.java:505)
	at org.eclipse.e4.ui.workbench.renderers.swt.LazyStackRenderer.postProcess(LazyStackRenderer.java:106)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.createGui(PartRenderingEngine.java:430)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.createGui(PartRenderingEngine.java:490)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$3.handleEvent(PartRenderingEngine.java:188)
	at org.eclipse.e4.ui.services.internal.events.UIEventHandler.handleEvent(UIEventHandler.java:41)
	at org.eclipse.equinox.internal.event.EventHandlerWrapper.handleEvent(EventHandlerWrapper.java:188)
	at org.eclipse.equinox.internal.event.EventHandlerTracker.dispatchEvent(EventHandlerTracker.java:198)
	at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230)
	at org.eclipse.osgi.framework.eventmgr.ListenerQueue.dispatchEventSynchronous(ListenerQueue.java:148)
	at org.eclipse.equinox.internal.event.EventAdminImpl.dispatchEvent(EventAdminImpl.java:139)
	at org.eclipse.equinox.internal.event.EventAdminImpl.sendEvent(EventAdminImpl.java:78)
	at org.eclipse.equinox.internal.event.EventComponent.sendEvent(EventComponent.java:39)
	at org.eclipse.e4.ui.services.internal.events.EventBroker.send(EventBroker.java:73)
	at org.eclipse.e4.ui.internal.workbench.UIEventPublisher.notifyChanged(UIEventPublisher.java:58)
	at org.eclipse.emf.common.notify.impl.BasicNotifierImpl.eNotify(BasicNotifierImpl.java:380)
	at org.eclipse.emf.common.notify.impl.NotificationImpl.dispatch(NotificationImpl.java:1033)
	at org.eclipse.emf.common.notify.impl.NotificationImpl.dispatch(NotificationImpl.java:1038)
	at org.eclipse.emf.common.notify.impl.NotifyingListImpl.addUnique(NotifyingListImpl.java:367)
	at org.eclipse.emf.common.util.AbstractEList.add(AbstractEList.java:345)
	at org.eclipse.e4.ui.workbench.addons.cleanupaddon.CleanupAddon$1$1.run(CleanupAddon.java:111)
	at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35)
	at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:134)

ERROR: Unable to create class 'org.eclipse.ui.internal.e4.compatibility.CompatibilityEditor' from bundle '4287'
org.eclipse.e4.core.di.InjectionException: Could not find satisfiable constructor in org.eclipse.ui.internal.e4.compatibility.CompatibilityEditor
	at org.eclipse.e4.core.internal.di.InjectorImpl.internalMake(InjectorImpl.java:301)
	at org.eclipse.e4.core.internal.di.InjectorImpl.make(InjectorImpl.java:219)
	at org.eclipse.e4.core.contexts.ContextInjectionFactory.make(ContextInjectionFactory.java:152)
	at org.eclipse.e4.ui.internal.workbench.ReflectionContributionFactory.createFromBundle(ReflectionContributionFactory.java:90)
	at org.eclipse.e4.ui.internal.workbench.ReflectionContributionFactory.doCreate(ReflectionContributionFactory.java:64)
	at org.eclipse.e4.ui.internal.workbench.ReflectionContributionFactory.create(ReflectionContributionFactory.java:53)
	at org.eclipse.e4.ui.workbench.renderers.swt.ContributedPartRenderer.createWidget(ContributedPartRenderer.java:51)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.createWidget(PartRenderingEngine.java:572)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.createGui(PartRenderingEngine.java:414)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.createGui(PartRenderingEngine.java:490)
	at org.eclipse.e4.ui.workbench.renderers.swt.StackRenderer.showTab(StackRenderer.java:505)
	at org.eclipse.e4.ui.workbench.renderers.swt.LazyStackRenderer.postProcess(LazyStackRenderer.java:106)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.createGui(PartRenderingEngine.java:430)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.createGui(PartRenderingEngine.java:490)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$3.handleEvent(PartRenderingEngine.java:188)
	at org.eclipse.e4.ui.services.internal.events.UIEventHandler.handleEvent(UIEventHandler.java:41)
	at org.eclipse.equinox.internal.event.EventHandlerWrapper.handleEvent(EventHandlerWrapper.java:188)
	at org.eclipse.equinox.internal.event.EventHandlerTracker.dispatchEvent(EventHandlerTracker.java:198)
	at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230)
	at org.eclipse.osgi.framework.eventmgr.ListenerQueue.dispatchEventSynchronous(ListenerQueue.java:148)
	at org.eclipse.equinox.internal.event.EventAdminImpl.dispatchEvent(EventAdminImpl.java:139)
	at org.eclipse.equinox.internal.event.EventAdminImpl.sendEvent(EventAdminImpl.java:78)
	at org.eclipse.equinox.internal.event.EventComponent.sendEvent(EventComponent.java:39)
	at org.eclipse.e4.ui.services.internal.events.EventBroker.send(EventBroker.java:73)
	at org.eclipse.e4.ui.internal.workbench.UIEventPublisher.notifyChanged(UIEventPublisher.java:58)
	at org.eclipse.emf.common.notify.impl.BasicNotifierImpl.eNotify(BasicNotifierImpl.java:380)
	at org.eclipse.emf.common.notify.impl.NotificationImpl.dispatch(NotificationImpl.java:1033)
	at org.eclipse.emf.common.notify.impl.NotificationImpl.dispatch(NotificationImpl.java:1038)
	at org.eclipse.emf.common.notify.impl.NotifyingListImpl.addUnique(NotifyingListImpl.java:367)
	at org.eclipse.emf.common.util.AbstractEList.add(AbstractEList.java:345)
	at org.eclipse.e4.ui.workbench.addons.cleanupaddon.CleanupAddon$1$1.run(CleanupAddon.java:111)
	at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35)
	at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:134)
Comment 1 Eric Moffatt CLA 2010-09-16 13:42:20 EDT
This is quite like the issues found in bug 325480. The main problem seems to be that we re-create the element (likely during the attempt to re-parent its containing stack).
Comment 2 Remy Suen CLA 2010-09-17 08:05:29 EDT
4. Drag the second editor back to the left to merge the two stacks back.

You get the same problem.
Comment 3 Eric Moffatt CLA 2010-09-17 10:35:26 EDT
Both end up invoking the same code. In both of these cases the the root cause is that the right-hand stack goes empty (and gets removed) and this causes the MPSC to only contain one element and the 'hall of mirrors' code 'unwraps' the remaining stack by removing the unnecessary MPSC.
Comment 4 Eric Moffatt CLA 2010-09-17 11:40:45 EDT
Gack!! this is worse than originally thought. I tried it moving two editors to the right and, as expected, dragging the first one back was fine (no cleanup required) but dragging the second one back threw the exceptions and *no* editor was available...

The base issue is that we're re-creating the editor but it's never been persisted. This means that the memento is not available but the normal case is that editors only get re-created due to lazy loading after a restart (where the memento would have been filled in).

The real fix is to make sure that the editor doesn't have to be re-created during *any* DnD operation but I have code that 'fixes' this by changing the EditorReference code to skip reading the memento if it's not there which might be a good thing to do.
Comment 5 Remy Suen CLA 2010-09-20 10:35:25 EDT
Eric, can this be closed or are you planning to do more work?
Comment 6 Eric Moffatt CLA 2010-09-23 13:57:44 EDT
I'm reworking my DnD now to handle the new MArea. I'll check to ensure that the scenario(s) here work and close it then...