Community
Participate
Working Groups
When you dispose the font set on the Control (Label for example) the Control continue to function without exception with some default system font. All sequential operations like layout, pack, computeSize are based on this default font. But Control#getFont() still returns the old disposed font. I think that Control#getFont() should return the font which is currently used by the Control and not the disposed one. Snippet: --- Label label = new Label( parent, SWT.NONE ); Font font = new Font( parent.getDisplay(), "Arial", 20, SWT.BOLD ); label.setText( "Test label" ); label.setFont( font ); font.dispose(); label.redraw(); parent.layout(); Font labelFont = label.getFont(); ---
You can not dispose the font that is still being used, some systems the application can crash if yo do that.
(In reply to comment #1) > You can not dispose the font that is still being used, some systems the > application can crash if yo do that. This is good news for RWT as it cannot work with disposed fonts either :) The use case described in bug 321135 is: when to dispose of a font (or any other resource) that is used for a specific widget and should be freed 'together' with the widget. Would it be legal to dispose of the font in the widgets dispose event?
(In reply to comment #2) > (In reply to comment #1) > > You can not dispose the font that is still being used, some systems the > > application can crash if yo do that. > This is good news for RWT as it cannot work with disposed fonts either :) > The use case described in bug 321135 is: when to dispose of a font (or any > other resource) that is used for a specific widget and should be freed > 'together' with the widget. > Would it be legal to dispose of the font in the widgets dispose event? Usually application store all the resouces they create and release them at the end (after the main event loop returns). See ControlExample for a example. But the answer is yes to your question, you can also use the dispose event of the Display, or just widget.dispose(); font.dispose(); // -> no one else references this font, you created the font explicitely.