Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 343389 - AIOOBE thrown when destroying the non-zeroth item when tabs are obscured
Summary: AIOOBE thrown when destroying the non-zeroth item when tabs are obscured
Status: RESOLVED FIXED
Alias: None
Product: e4
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 1.0   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 4.1   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 343440 (view as bug list)
Depends on:
Blocks:
 
Reported: 2011-04-20 08:13 EDT by Remy Suen CLA
Modified: 2011-05-30 10:47 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Remy Suen CLA 2011-04-20 08:13:24 EDT
1. Run the code below.
2. Resize the sash so that the tabs are obscured. Basically, drag the sash's line so it is on top of the second tab and then release the drag.
3. Now click the button on the right to dispose the second (index 1) item.
4. The program crashes with an AIOOBE.

Display display = new Display();
Shell shell = new Shell(display);
shell.setLayout(new FillLayout());

SashForm form = new SashForm(shell, SWT.HORIZONTAL);

CTabFolder folder = new CTabFolder(form, SWT.NONE);
CTabItem item1 = new CTabItem(folder, SWT.NONE);
item1.setText("abc");
item1.setControl(new Composite(folder, SWT.NONE));
final CTabItem item2 = new CTabItem(folder, SWT.NONE);
item2.setText("abc");
item2.setControl(new Composite(folder, SWT.NONE));
folder.setSelection(item2);

final Button b = new Button(form, SWT.PUSH);
b.addListener(SWT.Selection, new Listener() {
  public void handleEvent(Event event) {
    item2.dispose();
  }
});
form.setWeights(new int[] { 50, 50 });

shell.setSize(300, 200);
shell.open();
while (!shell.isDisposed()) {
  if (!display.readAndDispatch())
    display.sleep();
}
display.dispose();

----------------------

Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 1
	at org.eclipse.e4.ui.widgets.CTabFolder.computeControlBounds(CTabFolder.java:594)
	at org.eclipse.e4.ui.widgets.CTabFolder.getWrappedHeight(CTabFolder.java:3795)
	at org.eclipse.e4.ui.widgets.CTabFolder.getClientArea(CTabFolder.java:782)
	at org.eclipse.e4.ui.widgets.CTabFolder.setSelection(CTabFolder.java:2876)
	at org.eclipse.e4.ui.widgets.CTabFolder.setSelection(CTabFolder.java:2888)
	at org.eclipse.e4.ui.widgets.CTabFolder.destroyItem(CTabFolder.java:720)
	at org.eclipse.e4.ui.widgets.CTabItem.dispose(CTabItem.java:126)
	at Shelll$1.handleEvent(Shelll.java:48)
	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:4163)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3752)
	at Shelll.main(Shelll.java:56)
Comment 1 Remy Suen CLA 2011-04-20 13:28:31 EDT
Olivier, this is the CTabFolder bug that's caused by the first item being obscured if the stack is resized "too small".
Comment 2 Bogdan Gheorghe CLA 2011-04-26 23:07:54 EDT
Fixed in HEAD > 20110426
Comment 3 Remy Suen CLA 2011-04-27 09:56:16 EDT
*** Bug 343440 has been marked as a duplicate of this bug. ***