Committed by
David PHAM-VAN
fix crash when Android load a PDF file which had password
Showing
3 changed files
with
15 additions
and
1 deletions
@@ -507,6 +507,19 @@ public class PrintingJob extends PrintDocumentAdapter { | @@ -507,6 +507,19 @@ public class PrintingJob extends PrintDocumentAdapter { | ||
507 | } | 507 | } |
508 | }); | 508 | }); |
509 | 509 | ||
510 | + thread.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { | ||
511 | + @Override | ||
512 | + public void uncaughtException(Thread t, Throwable e) { | ||
513 | + final String finalError = e.getMessage(); | ||
514 | + new Handler(Looper.getMainLooper()).post(new Runnable() { | ||
515 | + @Override | ||
516 | + public void run() { | ||
517 | + printing.onPageRasterEnd(PrintingJob.this, finalError); | ||
518 | + } | ||
519 | + }); | ||
520 | + } | ||
521 | + }); | ||
522 | + | ||
510 | thread.start(); | 523 | thread.start(); |
511 | } | 524 | } |
512 | } | 525 | } |
@@ -93,7 +93,7 @@ public class PrintJob: UIPrintPageRenderer, UIPrintInteractionControllerDelegate | @@ -93,7 +93,7 @@ public class PrintJob: UIPrintPageRenderer, UIPrintInteractionControllerDelegate | ||
93 | } | 93 | } |
94 | 94 | ||
95 | let printer = UIPrinter(url: printerURL!) | 95 | let printer = UIPrinter(url: printerURL!) |
96 | - printer.contactPrinter { available -> Void in | 96 | + printer.contactPrinter { available in |
97 | if !available { | 97 | if !available { |
98 | printing.onCompleted(printJob: self, completed: false, error: "Printer not available") | 98 | printing.onCompleted(printJob: self, completed: false, error: "Printer not available") |
99 | return | 99 | return |
-
Please register or login to post a comment