From bebfa839daf5f2792bb146f1d734d4b18f09d5ca Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Fri, 21 Feb 2014 00:51:34 +0000 Subject: [PATCH] Fix fall back to default resolution in wxOSX printing code. The code was written to use the default resolution if getting it from the printer failed but only handled failure of PMPrinterGetOutputResolution() and not of PMSessionGetCurrentPrinter() itself. Use default resolution if obtaining it failed for any reason (alternative could be to return error if obtaining it failed for any return...). git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@75951 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/osx/carbon/dcprint.cpp | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/osx/carbon/dcprint.cpp b/src/osx/carbon/dcprint.cpp index e7f42f9b95..4b60a428a5 100644 --- a/src/osx/carbon/dcprint.cpp +++ b/src/osx/carbon/dcprint.cpp @@ -141,17 +141,24 @@ bool wxMacCarbonPrinterDC::StartDoc( wxPrinterDC* dc , const wxString& message PMResolution res; PMPrinter printer; + bool useDefaultResolution = true; m_err = PMSessionGetCurrentPrinter(native->GetPrintSession(), &printer); if (m_err == noErr) { m_err = PMPrinterGetOutputResolution( printer, native->GetPrintSettings(), &res) ; - if ( m_err == -9589 /* kPMKeyNotFound */ ) - { - m_err = noErr ; - res.hRes = res.vRes = 300; - } + if (m_err == noErr) + useDefaultResolution = true; } + // Ignore errors which may occur while retrieving the resolution and just + // use the default one. + if ( useDefaultResolution ) + { + res.hRes = + res.vRes = 300; + m_err = noErr ; + } + m_maxX = wxCoord((double)m_maxX * res.hRes / 72.0); m_maxY = wxCoord((double)m_maxY * res.vRes / 72.0);