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
This commit is contained in:
Vadim Zeitlin 2014-02-21 00:51:34 +00:00
parent 356da1750d
commit bebfa839da

View File

@ -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);