mirror of https://github.com/noisymime/Arduino.git
Do not cache PrinterJob instances. Cache is evil
This commit is contained in:
parent
a9cdd44d27
commit
8c83281a19
|
@ -119,7 +119,6 @@ public class Editor extends JFrame implements RunnerListener {
|
||||||
boolean untitled;
|
boolean untitled;
|
||||||
|
|
||||||
PageFormat pageFormat;
|
PageFormat pageFormat;
|
||||||
PrinterJob printerJob;
|
|
||||||
|
|
||||||
// file, sketch, and tools menus for re-inserting items
|
// file, sketch, and tools menus for re-inserting items
|
||||||
JMenu fileMenu;
|
JMenu fileMenu;
|
||||||
|
@ -2760,15 +2759,11 @@ public class Editor extends JFrame implements RunnerListener {
|
||||||
* Handler for File → Page Setup.
|
* Handler for File → Page Setup.
|
||||||
*/
|
*/
|
||||||
public void handlePageSetup() {
|
public void handlePageSetup() {
|
||||||
//printerJob = null;
|
PrinterJob printerJob = PrinterJob.getPrinterJob();
|
||||||
if (printerJob == null) {
|
|
||||||
printerJob = PrinterJob.getPrinterJob();
|
|
||||||
}
|
|
||||||
if (pageFormat == null) {
|
if (pageFormat == null) {
|
||||||
pageFormat = printerJob.defaultPage();
|
pageFormat = printerJob.defaultPage();
|
||||||
}
|
}
|
||||||
pageFormat = printerJob.pageDialog(pageFormat);
|
pageFormat = printerJob.pageDialog(pageFormat);
|
||||||
//System.out.println("page format is " + pageFormat);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -2778,9 +2773,7 @@ public class Editor extends JFrame implements RunnerListener {
|
||||||
public void handlePrint() {
|
public void handlePrint() {
|
||||||
statusNotice(_("Printing..."));
|
statusNotice(_("Printing..."));
|
||||||
//printerJob = null;
|
//printerJob = null;
|
||||||
if (printerJob == null) {
|
PrinterJob printerJob = PrinterJob.getPrinterJob();
|
||||||
printerJob = PrinterJob.getPrinterJob();
|
|
||||||
}
|
|
||||||
if (pageFormat != null) {
|
if (pageFormat != null) {
|
||||||
//System.out.println("setting page format " + pageFormat);
|
//System.out.println("setting page format " + pageFormat);
|
||||||
printerJob.setPrintable(textarea, pageFormat);
|
printerJob.setPrintable(textarea, pageFormat);
|
||||||
|
|
Loading…
Reference in New Issue