changeset 7199:d9e26c986af1

Fixed RT-37209) [Printing] NPE when showing print dialog Reviewed-by: kcr
author prr
date Thu, 05 Jun 2014 15:57:41 -0700
parents d04c6e8ba00a
children e2d745ffbf0a
files modules/graphics/src/main/java/com/sun/prism/j2d/print/J2DPrinter.java modules/graphics/src/main/java/com/sun/prism/j2d/print/J2DPrinterJob.java
diffstat 2 files changed, 5 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/modules/graphics/src/main/java/com/sun/prism/j2d/print/J2DPrinter.java	Thu Jun 05 14:44:27 2014 -0600
+++ b/modules/graphics/src/main/java/com/sun/prism/j2d/print/J2DPrinter.java	Thu Jun 05 15:57:41 2014 -0700
@@ -839,7 +839,7 @@
             MediaPrintableArea[] mpa = (MediaPrintableArea[])service.
                 getSupportedAttributeValues(MediaPrintableArea.class,
                                             null, pras);
-            if (mpa != null && mpa.length > 0) {
+            if (mpa != null && mpa.length > 0 && mpa[0] != null) {
                 int MPA_INCH = MediaPrintableArea.INCH;
                 area = new Rectangle2D(mpa[0].getX(MPA_INCH),
                                        mpa[0].getY(MPA_INCH),
--- a/modules/graphics/src/main/java/com/sun/prism/j2d/print/J2DPrinterJob.java	Thu Jun 05 14:44:27 2014 -0600
+++ b/modules/graphics/src/main/java/com/sun/prism/j2d/print/J2DPrinterJob.java	Thu Jun 05 15:57:41 2014 -0700
@@ -389,6 +389,10 @@
                 bm = pWid - mpaX - mpaW;
                 break;
             }
+            if (Math.abs(lm) < 0.01) lm = 0;
+            if (Math.abs(rm) < 0.01) rm = 0;
+            if (Math.abs(tm) < 0.01) tm = 0;
+            if (Math.abs(bm) < 0.01) bm = 0;
             newLayout = fxPrinter.createPageLayout(paper, orient,
                                                    lm, rm, tm, bm);
         }