birt
birt copied to clipboard
TextCombo used in JSEdtior is leaking graphic contexts (gc)
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();
}
});
}