Project: SWT
Bug 320484 Weak FontData hashCode
Reported: 2010-07-21 06:46:38 | Status: resolved fixed

The following font datas all produce the same hash code: new FontData( "Times", 15, SWT.NORMAL ).hashCode(); new FontData( "Times", 14, SWT.BOLD ).hashCode(); new FontData( "Times", 13, SWT.ITALIC ).hashCode(); new FontData( "Times", 12, SWT.BOLD | SWT.ITALIC ).hashCode(); This can be fixed by changing FontData hashCode from: return name.hashCode() ^ getHeight() ^ style; to: return name.hashCode() ^ getHeight() << 2 ^ style;

Files changed in fix:
bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/graphics/FontData.java bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/graphics/FontData.java bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/FontData.java bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/FontData.java bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/FontData.java bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/graphics/FontData.java