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

Bug 347831

Summary: IAE thrown when dropping first view on itself
Product: [Eclipse Project] e4 Reporter: Remy Suen <remy.suen>
Component: UIAssignee: Project Inbox <e4.ui-inbox>
Status: RESOLVED WORKSFORME QA Contact: Eric Moffatt <emoffatt>
Severity: major    
Priority: P3 Flags: emoffatt: review+
Version: 1.0   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
Prevent the 'dropIndex' from ever going below zero
none
StackDropAgent patch v2 none

Description Remy Suen CLA 2011-05-31 13:08:27 EDT
1. Click and drag the 'Problems' view.
2. Drop it on its own tab.
3. An IAE is thrown.

java.lang.IllegalArgumentException: Index out of bounds
	at org.eclipse.swt.SWT.error(SWT.java:4258)
	at org.eclipse.swt.SWT.error(SWT.java:4192)
	at org.eclipse.swt.SWT.error(SWT.java:4163)
	at org.eclipse.e4.ui.widgets.CTabFolder.getItem(CTabFolder.java:821)
	at org.eclipse.e4.ui.workbench.addons.dndaddon.StackDropAgent.dock(StackDropAgent.java:227)
	at org.eclipse.e4.ui.workbench.addons.dndaddon.StackDropAgent.drop(StackDropAgent.java:292)
	at org.eclipse.e4.ui.workbench.addons.dndaddon.DnDManager.finishDrag(DnDManager.java:257)
	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:4163)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3752)
Comment 1 Eric Moffatt CLA 2011-06-01 16:16:36 EDT
Created attachment 197166 [details]
Prevent the 'dropIndex' from ever going below zero


This is a 'point fix', I'll revisit the logic post-4.1.
Comment 2 Eric Moffatt CLA 2011-06-01 16:17:22 EDT
Remy, not the best solution but it works, take a look please.
Comment 3 Remy Suen CLA 2011-06-01 16:33:14 EDT
Created attachment 197172 [details]
StackDropAgent patch v2

The conditional change looks good to me but it doesn't seem like the getDropIndex(DnDInfo) change is necessary so I think we should leave that method as-is.
Comment 4 Remy Suen CLA 2011-06-01 16:34:10 EDT
(In reply to comment #3)
> Created attachment 197172 [details]
> StackDropAgent patch v2

Eric, please look at this and commit if you're fine with it.
Comment 5 Eric Moffatt CLA 2011-06-01 16:38:16 EDT
Remy's patch is better...I'm going to commit this just to avoid the IAE but won't mark this defect as fixed yet because there's still odd behavior when dropping an item onto itself (if it's to the left side of the item then the tab item moves left when it should not...).

Committed in >20110601. Applied Remy's version...
Comment 6 Dani Megert CLA 2013-06-05 10:57:38 EDT
Removing outdated target milestone.
Comment 7 Eric Moffatt CLA 2013-06-06 11:39:18 EDT
This issue has been fixed for some time, including the bad drop behavior...