Bug 160122 - [Forms] Hyperlink's font gets disposed during the application runtime
Summary: [Forms] Hyperlink's font gets disposed during the application runtime
Status: CLOSED WONTFIX
Alias: None
Product: Platform
Classification: Eclipse Project
Component: User Assistance (show other bugs)
Version: 3.2   Edit
Hardware: PC Linux-GTK
: P2 major (vote)
Target Milestone: ---   Edit
Assignee: platform-ua-inbox CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords: needinfo
Depends on:
Blocks:
 
Reported: 2006-10-07 04:58 EDT by Michael Spector CLA
Modified: 2019-11-14 02:13 EST (History)
3 users (show)

See Also:


Attachments
My Eclipse config. (24.71 KB, application/octet-stream)
2006-10-07 05:01 EDT, Michael Spector CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Spector CLA 2006-10-07 04:58:19 EDT
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.
Comment 1 Michael Spector CLA 2006-10-07 05:01:34 EDT
Created attachment 51596 [details]
My Eclipse config.
Comment 2 Chris Aniszczyk CLA 2006-10-09 12:02:49 EDT
punting to the father of Forms
Comment 3 Dejan Glozic CLA 2006-11-14 17:47:12 EST
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?
Comment 4 Michael Spector CLA 2006-11-15 00:22:41 EST
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.
Comment 5 Dejan Glozic CLA 2006-11-15 08:04:29 EST
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?
Comment 6 Grant Gayed CLA 2006-12-04 16:22:16 EST
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.
Comment 7 Chris Goldthorpe CLA 2011-04-20 15:55:59 EDT
Is this problem still happening?
Comment 8 Lars Vogel CLA 2019-11-14 02:13:02 EST
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.