birt icon indicating copy to clipboard operation
birt copied to clipboard

TextCombo used in JSEdtior is leaking graphic contexts (gc)

Open claesrosell opened this issue 3 years ago • 0 comments

Guilty code, the GC created is never disposed. Easy enough. However, from the look of this code I think that we should reconsider how the bold font is retrieved and what the protected member "itemHeight" is used for.

org.eclipse.birt.core.ui.swt.custom.TextCombo:

	public TextCombo(Composite parent, int style) {
		super(parent, style);

		GC gc = new GC(this);
		itemHeight = gc.getFontMetrics().getHeight() + 2;

		if (gc.getFont().getFontData() == null || gc.getFont().getFontData().length == 0) {
			fontBold = new Font(Display.getCurrent(), "arial", //$NON-NLS-1$
					9, SWT.BOLD);
		} else {
			FontData fd = gc.getFont().getFontData()[0];
			fontBold = new Font(gc.getDevice(), fd.getName(), fd.getHeight(), fd.getStyle() | SWT.BOLD);
		}
		addDisposeListener(new DisposeListener() {

			public void widgetDisposed(DisposeEvent e) {
				fontBold.dispose();
				choiceMarkerMap.clear();
			}
		});
	}

claesrosell avatar Feb 27 '22 20:02 claesrosell