Community
Participate
Working Groups
From time to time I get this weird exception: java.lang.IllegalArgumentException: Argument not valid at org.eclipse.swt.SWT.error(SWT.java:3358) at org.eclipse.swt.SWT.error(SWT.java:3297) at org.eclipse.swt.SWT.error(SWT.java:3268) at org.eclipse.swt.graphics.GC.setFont(GC.java:2920) at org.eclipse.ui.forms.widgets.Hyperlink.paintText(Hyperlink.java:177) at org.eclipse.ui.forms.widgets.Hyperlink.paintHyperlink(Hyperlink.java:165) at org.eclipse.ui.forms.widgets.AbstractHyperlink.paint(AbstractHyperlink.java:265) at org.eclipse.ui.forms.widgets.AbstractHyperlink$2.paintControl(AbstractHyperlink.java:72) at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:83) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:66) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1085) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1109) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1094) at org.eclipse.swt.widgets.Control.gtk_expose_event(Control.java:2024) at org.eclipse.swt.widgets.Composite.gtk_expose_event(Composite.java:605) at org.eclipse.swt.widgets.Canvas.gtk_expose_event(Canvas.java:133) at org.eclipse.swt.widgets.Widget.windowProc(Widget.java:1430) at org.eclipse.swt.widgets.Display.windowProc(Display.java:3796) 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:5245) at org.eclipse.swt.widgets.Display.eventProc(Display.java:1133) at org.eclipse.swt.internal.gtk.OS._g_main_context_iteration(Native Method) at org.eclipse.swt.internal.gtk.OS.g_main_context_iteration(OS.java:1427) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2838) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1914) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1878) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:419) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149) My Eclipse config is attached.
Created attachment 51596 [details] My Eclipse config.
punting to the father of Forms
The hyperlink color management is currently flawed in that it borrows the colors from JFaceColors (which delegates to ColorRegistry), and hangs onto these Color objects. These colors can be disposed when the setting changes via the preference page. We need to somehow add ourselves as resource listeners for these colors. However, I would hate adding each hyperlink group as a listener to the color registry. We need to carefully fix this one. Can you clarify 'from time to time'? Is there a repeatable sequence of steps that causes this exception to be thrown?
Nope... I have a FormEditor with multiple FormPage's, when moving between tabs - it happens occasionally, with no reproduction scenario. My workaround was: to change the type of Section to non-expandable.
In that case, the title of the bug may be incorrect. The exception claims that 'Argument is not valid', not that it has been disposed. It is possible that font is null, not disposed. Moving to SWT team for comment. The code in question is: protected void paintText(GC gc, Rectangle bounds) { gc.setFont(getFont()); <--- line 177 gc.setForeground(getForeground()); Hyperlink class extends Canvas. My assumption has been that 'getFont' should always return a valid font even if 'setFont(null)' has been used. What does 'Argument no valid' mean - that Font resource has been disposed or something else?
A disposed font is being answered by getFont(), so the font that was previously set into your Canvas subclass has been prematurely disposed bby someone while it's still being used. Using a small test snippet it appears that in this scenario getFont() will not answer a disposed font on win32, so there is a platform difference here that makes your scenario not fail on win32. However this behaviour is not spec'd and cannot be counted on. Returning report to UA since disposing a font that is still in use is never valid.
Is this problem still happening?
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant. If the bug is still relevant, please remove the "stalebug" whiteboard tag.