src/macosx/classes/sun/lwawt/macosx/CPrinterJob.java
Print this page
*** 45,54 ****
--- 45,58 ----
// are handled by the native printing. RasterPrinterJob is kept for
// future compatibility and the state keeping that it handles.
private static String sShouldNotReachHere = "Should not reach here.";
+ private final SecondaryLoop printingLoop = Toolkit.getDefaultToolkit()
+ .getSystemEventQueue()
+ .createSecondaryLoop();
+
private boolean noDefaultPrinter = false;
private static Font defaultFont;
// This is the NSPrintInfo for this PrinterJob. Protect multi thread
*** 158,172 ****
--- 162,189 ----
}
}
volatile boolean onEventThread;
+ @Override
+ public void cancel() {
+ super.cancel();
+ printingLoop.exit();
+ }
+
+ @Override
+ protected void cancelDoc() throws PrinterAbortException {
+ super.cancelDoc();
+ printingLoop.exit();
+ }
+
private void completePrintLoop() {
Runnable r = new Runnable() { public void run() {
synchronized(this) {
performingPrinting = false;
}
+ printingLoop.exit();
}};
if (onEventThread) {
try { EventQueue.invokeAndWait(r); } catch (Exception e) { e.printStackTrace(); }
} else {
*** 221,237 ****
try {
// Fire off the print rendering loop on the AppKit thread, and don't have
// it wait and block this thread.
if (printLoop(false, firstPage, lastPage)) {
! // Fire off the EventConditional that will what until the condition is met,
! // but will still process AWTEvent's as they occur.
! new EventDispatchAccess() {
! public boolean evaluate() {
! return performingPrinting;
! }
! }.pumpEventsAndWait();
}
} catch (Exception e) {
e.printStackTrace();
}
} else {
--- 238,249 ----
try {
// Fire off the print rendering loop on the AppKit thread, and don't have
// it wait and block this thread.
if (printLoop(false, firstPage, lastPage)) {
! // Start a secondary loop on EDT until printing operation is finished or cancelled
! printingLoop.enter();
}
} catch (Exception e) {
e.printStackTrace();
}
} else {
*** 249,258 ****
--- 261,271 ----
} finally {
synchronized (this) {
// NOTE: Native code shouldn't allow exceptions out while
// printing. They should cancel the print loop.
performingPrinting = false;
+ printingLoop.exit();
notify();
}
}
// Normalize the collated, # copies, numPages, first/last pages. Need to