Community
Participate
Working Groups
java.lang.NullPointerException at org.eclipse.gmf.runtime.draw2d.ui.internal.graphics.PrinterGraphics.dispose(PrinterGraphics.java:73) at org.eclipse.gmf.runtime.diagram.ui.printing.internal.util.DiagramPrinter.dispose(DiagramPrinter.java:533) at org.eclipse.gmf.runtime.diagram.ui.printing.internal.util.DiagramPrinter.run(DiagramPrinter.java:213) at org.eclipse.gmf.runtime.diagram.ui.printing.util.DiagramPrinterUtil.printDiagrams(DiagramPrinterUtil.java:66) etc.... you won't see an exception in the log, but the exception does occur. The problem can contribute to a SWT handle leak. In org.eclipse.gmf.runtime.draw2d.ui.internal.graphics.PrinterGraphics#dispose the code tries to dispose all the images in collapseImageCache, but if any are already disposed there hashCode has changed and HashMap#get will return null. A better approach is to iterate over the values which will never be null. An image can safely be disposed twice. The suggested code below is similar to that found in the base class. public void dispose() { for (Iterator it = collapseImageCache.values().iterator(); it.hasNext();) { Image img = (Image) it.next(); img.dispose(); } collapseImageCache.clear(); super.dispose(); }
This issue is not specific to PC hardware or the Windows OS: both should be 'all' but I can't change those fields.
Created attachment 53376 [details] patch Attached patch. Verified that exception no longer occurs in dispose method.
Reviewed and committed the patch.
[target cleanup] 2.0 M4 was the original target milestone for this bug
[GMF Restructure] Bug 319140 : product GMF and component Runtime was the original product and component for this bug