Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 347831 - IAE thrown when dropping first view on itself
Summary: IAE thrown when dropping first view on itself
Status: RESOLVED WORKSFORME
Alias: None
Product: e4
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 1.0   Edit
Hardware: PC Windows XP
: P3 major (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact: Eric Moffatt CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-05-31 13:08 EDT by Remy Suen CLA
Modified: 2013-06-06 11:39 EDT (History)
0 users

See Also:
emoffatt: review+


Attachments
Prevent the 'dropIndex' from ever going below zero (1.06 KB, patch)
2011-06-01 16:16 EDT, Eric Moffatt CLA
no flags Details | Diff
StackDropAgent patch v2 (1.32 KB, patch)
2011-06-01 16:33 EDT, Remy Suen CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
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...