Community
Participate
Working Groups
When I show a PrintDialog then use the resulting PrinterData to create a print job it crashes the JVM. This is affecting all my users on Mac Big Sur. Here's an example: package org.eclipse.swt.printing; import org.eclipse.swt.*; import org.eclipse.swt.graphics.*; import org.eclipse.swt.widgets.*; public class Snippet132WithDialog { public static void main (String [] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setText("Snippet 132 Modified"); shell.open (); PrintDialog dialog = new PrintDialog(shell); final PrinterData printData = dialog.open(); if (printData == null) { return; } Printer printer = new Printer(printData); System.out.println("Point A"); if (printer.startJob("SWT Printing Snippet")) { System.out.println("Point B"); Color black = printer.getSystemColor(SWT.COLOR_BLACK); Color white = printer.getSystemColor(SWT.COLOR_WHITE); Color red = printer.getSystemColor(SWT.COLOR_RED); Rectangle trim = printer.computeTrim(0, 0, 0, 0); Point dpi = printer.getDPI(); int leftMargin = dpi.x + trim.x; // one inch from left side of paper if (leftMargin < 0) leftMargin = -trim.x; // make sure to print on the printable area int topMargin = dpi.y / 2 + trim.y; // one-half inch from top edge of paper if (topMargin < 0) topMargin = -trim.y; // make sure to print on the printable area GC gc = new GC(printer); if (printer.startPage()) { gc.setBackground(white); gc.setForeground(black); String testString = "Hello World!"; Point extent = gc.stringExtent(testString); gc.drawString(testString, leftMargin, topMargin); gc.setForeground(red); gc.drawRectangle(leftMargin, topMargin, extent.x, extent.y); printer.endPage(); } gc.dispose(); printer.endJob(); } printer.dispose(); while (!shell.isDisposed ()) { if (!display.readAndDispatch ()) display.sleep (); } display.dispose(); } } In the output I can see 'Point A' but not 'Point B'. Instead I get the following core dump: # # A fatal error has been detected by the Java Runtime Environment: # # SIGSEGV (0xb) at pc=0x00007fff2059e650, pid=1966, tid=0x0000000000000103 # # JRE version: Java(TM) SE Runtime Environment (8.0_162-b12) (build 1.8.0_162-b12) # Java VM: Java HotSpot(TM) 64-Bit Server VM (25.162-b12 mixed mode bsd-amd64 compressed oops) # Problematic frame: # C [CoreFoundation+0x9650] CFStringGetCString+0x254 # # Failed to write core dump. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again #
Which version of Eclipse do you see this? Can you please attach the console log for the crash?
I'm unable to reproduce the problem with the snippet on macOS BigSur and Eclipse 4.22. Both Point A and Point B is printed and there is no crash. Please reopen if you still see the problem with the latest Eclipse.