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

Bug 309443

Summary: [Forms] Section with zero size causes exception
Product: [Eclipse Project] Platform Reporter: Konstantin Scheglov <Konstantin.Scheglov>
Component: User AssistanceAssignee: platform-ua-inbox <platform-ua-inbox>
Status: CLOSED DUPLICATE QA Contact:
Severity: normal    
Priority: P3 CC: cgold, dgolovin, jonah, pwebster, remy.suen, snjezana.peco, waqas.ilyas
Version: 3.5.2Keywords: helpwanted
Target Milestone: ---   
Hardware: PC   
OS: Windows Vista   
Whiteboard:
Attachments:
Description Flags
Test case
none
Example reported by our user
none
Code snippet to reproduce the problem none

Description Konstantin Scheglov CLA 2010-04-16 05:33:00 EDT
Build Identifier: I20100217-1031

Run attached application and click Button.
Application will be terminated and following exception dumped on console.
It seems that Section should check for zero size and avoid Image creation in this case.

java.lang.IllegalArgumentException: Argument not valid
	at org.eclipse.swt.SWT.error(SWT.java:4064)
	at org.eclipse.swt.SWT.error(SWT.java:3998)
	at org.eclipse.swt.SWT.error(SWT.java:3969)
	at org.eclipse.swt.graphics.Image.init(Image.java:1562)
	at org.eclipse.swt.graphics.Image.<init>(Image.java:177)
	at org.eclipse.ui.forms.widgets.Section.onPaint(Section.java:344)
	at org.eclipse.ui.forms.widgets.ExpandableComposite$1.paintControl(ExpandableComposite.java:555)
	at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:217)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1050)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1074)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1059)
	at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:773)
	at test.Application_1$1.widgetSelected(Application_1.java:66)
	at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:228)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1050)
	at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4010)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3601)
	at test.Application_1.open(Application_1.java:42)
	at test.Application_1.main(Application_1.java:28)


Reproducible: Always
Comment 1 Konstantin Scheglov CLA 2010-04-16 05:33:39 EDT
Created attachment 165072 [details]
Test case
Comment 2 Remy Suen CLA 2010-04-16 06:01:39 EDT
The Forms API is owned by UA.
Comment 3 Chris Goldthorpe CLA 2010-04-16 17:32:09 EDT
What's the scenario where the size ends up being 0. The image creation is not the only part of the code that will fail if the size is 0.
Comment 4 Konstantin Scheglov CLA 2010-04-17 03:31:27 EDT
Created attachment 165175 [details]
Example reported by our user

Is this important?
I saw this problem couple times in the past, usually this is caused by some layout nuances.
Zero size is not a bug of user, right? So, would be nice to make Section more robust to such situation.
Comment 5 Waqas Ilyas CLA 2013-01-02 07:33:49 EST
Created attachment 225136 [details]
Code snippet to reproduce the problem

I am also seeing this exact same defect.

Eclipse: Version: 3.8.0, Build id: I20120608-1200 (32-bit)
JRE: jdk1.7.0_07 (32-bit)
OS: Windows 7 Enterprise, Service Pack 1 (64-bit)

I have attached a small code snippet to easily reproduce the problem. Run the code and press the "Add" button on the dialog to produce the exception.

If you see, I have called a method called "addSection" in the attached program when the button is clicked. This same method is also called when the shell is not open yet and it runs without any problems. But once the shell is open you can reproduce the problem on each call. 

You will also notice that when the exception occurs I am just creating a new section and adding children to it. If any direct child of the Section is modified (via setText in this example) it triggers a paint event onto the Section. The section was just added and the layout manager did not get a chance to compute control sizes, so it has a zero size. This happens only on Windows 7 and is not reproducible on Windows XP (the paint event does not occur).
Comment 6 Jonah Graham CLA 2015-01-22 09:40:19 EST
I get this exception on Eclipse Mars M4 very often when opening the ManifestEditor.

Here is my full stack trace:

!ENTRY org.eclipse.ui 4 0 2015-01-22 14:13:54.701
!MESSAGE Unhandled event loop exception
!STACK 0
java.lang.IllegalArgumentException: Argument not valid
	at org.eclipse.swt.SWT.error(SWT.java:4446)
	at org.eclipse.swt.SWT.error(SWT.java:4380)
	at org.eclipse.swt.SWT.error(SWT.java:4351)
	at org.eclipse.swt.graphics.Image.init(Image.java:1294)
	at org.eclipse.swt.graphics.Image.<init>(Image.java:200)
	at org.eclipse.ui.forms.widgets.Section.onPaint(Section.java:344)
	at org.eclipse.ui.forms.widgets.ExpandableComposite$1.paintControl(ExpandableComposite.java:561)
	at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:230)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
	at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4466)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1393)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1417)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1402)
	at org.eclipse.swt.widgets.Control.gtk_draw(Control.java:3185)
	at org.eclipse.swt.widgets.Canvas.gtk_draw(Canvas.java:171)
	at org.eclipse.swt.widgets.Widget.windowProc(Widget.java:2065)
	at org.eclipse.swt.widgets.Control.windowProc(Control.java:5524)
	at org.eclipse.swt.widgets.Display.windowProc(Display.java:4698)
	at org.eclipse.swt.internal.gtk.OS._gtk_main_do_event(Native Method)
	at org.eclipse.swt.internal.gtk.OS.gtk_main_do_event(OS.java:9158)
	at org.eclipse.swt.widgets.Display.eventProc(Display.java:1253)
	at org.eclipse.swt.internal.gtk.OS._gdk_window_process_all_updates(Native Method)
	at org.eclipse.swt.internal.gtk.OS.gdk_window_process_all_updates(OS.java:5964)
	at org.eclipse.swt.widgets.Display.update(Display.java:4651)
	at org.eclipse.swt.widgets.Display.runDeferredLayouts(Display.java:3830)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3401)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$9.run(PartRenderingEngine.java:1151)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:337)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1032)
	at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:148)
	at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:648)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:337)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:592)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:150)
	at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:138)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:134)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:380)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:235)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:606)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:648)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:603)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1465)
	at org.eclipse.equinox.launcher.Main.main(Main.java:1438)
Comment 7 Snjezana Peco CLA 2015-04-09 11:21:19 EDT

*** This bug has been marked as a duplicate of bug 460286 ***