From 444e971790247d9d580b21df232399219725c509 Mon Sep 17 00:00:00 2001 From: alitvinov Date: Tue, 6 Jun 2017 19:02:21 +0300 Subject: [PATCH] 8181192: [macos] javafx.print.PrinterJob.showPrintDialog() hangs on macOS Reviewed-by: prr, serb --- src/macosx/native/sun/awt/CPrinterJob.m | 4 ++-- src/share/classes/sun/print/RasterPrinterJob.java | 8 ++++++++ .../java/awt/print/PageFormat/WrongPaperPrintingTest.java | 1 + 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/macosx/native/sun/awt/CPrinterJob.m b/src/macosx/native/sun/awt/CPrinterJob.m index fdd56fd41..d9154fa4f 100644 --- a/src/macosx/native/sun/awt/CPrinterJob.m +++ b/src/macosx/native/sun/awt/CPrinterJob.m @@ -365,7 +365,7 @@ static void javaPrinterJobToNSPrintInfo(JNIEnv* env, jobject srcPrinterJob, jobj static JNF_MEMBER_CACHE(jm_getMaxPage, sjc_CPrinterJob, "getMaxPageAttrib", "()I"); static JNF_MEMBER_CACHE(jm_getSelectAttrib, sjc_CPrinterJob, "getSelectAttrib", "()I"); static JNF_MEMBER_CACHE(jm_getNumberOfPages, jc_Pageable, "getNumberOfPages", "()I"); - static JNF_MEMBER_CACHE(jm_getPageFormat, sjc_CPrinterJob, "getPageFormat", "(I)Ljava/awt/print/PageFormat;"); + static JNF_MEMBER_CACHE(jm_getPageFormat, sjc_CPrinterJob, "getPageFormatFromAttributes", "()Ljava/awt/print/PageFormat;"); NSMutableDictionary* printingDictionary = [dst dictionary]; @@ -401,7 +401,7 @@ static void javaPrinterJobToNSPrintInfo(JNIEnv* env, jobject srcPrinterJob, jobj [printingDictionary setObject:[NSNumber numberWithInteger:fromPage] forKey:NSPrintFirstPage]; [printingDictionary setObject:[NSNumber numberWithInteger:toPage] forKey:NSPrintLastPage]; - jobject page = JNFCallObjectMethod(env, srcPrinterJob, jm_getPageFormat, (jint)0); + jobject page = JNFCallObjectMethod(env, srcPrinterJob, jm_getPageFormat); if (page != NULL) { javaPageFormatToNSPrintInfo(env, NULL, page, dst); } diff --git a/src/share/classes/sun/print/RasterPrinterJob.java b/src/share/classes/sun/print/RasterPrinterJob.java index eb2b5cf65..1bb3dad5f 100644 --- a/src/share/classes/sun/print/RasterPrinterJob.java +++ b/src/share/classes/sun/print/RasterPrinterJob.java @@ -818,6 +818,14 @@ public abstract class RasterPrinterJob extends PrinterJob { } } + protected PageFormat getPageFormatFromAttributes() { + if (attributes == null || attributes.isEmpty()) { + return null; + } + return attributeToPageFormat(getPrintService(), this.attributes); + } + + /** * Presents the user a dialog for changing properties of the * print job interactively. diff --git a/test/java/awt/print/PageFormat/WrongPaperPrintingTest.java b/test/java/awt/print/PageFormat/WrongPaperPrintingTest.java index 79f07489e..2299015b2 100644 --- a/test/java/awt/print/PageFormat/WrongPaperPrintingTest.java +++ b/test/java/awt/print/PageFormat/WrongPaperPrintingTest.java @@ -24,6 +24,7 @@ /* @test @bug 8167102 @summary PrintRequestAttributeSet breaks page size set using PageFormat + @ignore Exclude the test until 8167102 is resolved by a new reassessed fix @run main/manual WrongPaperPrintingTest */ -- GitLab