summaryrefslogtreecommitdiff
path: root/vcl/source/gdi
diff options
context:
space:
mode:
authorMichael Meeks <michael.meeks@collabora.com>2017-03-23 11:24:22 +0000
committerMichael Meeks <michael.meeks@collabora.com>2017-03-24 11:17:37 +0000
commita298648302b4ba7765816f3fbe4d89c0cfcb3a57 (patch)
tree2b386de15920600b8800ef8efe867c842fe488a3 /vcl/source/gdi
parent0b67b1229a92adf68b614fe53f84bb19780553bf (diff)
vcl printer: hold a reference on mxPrinter member while operating on it.
Hopefully addresses: http://crashreport.libreoffice.org/stats/crash_details/7a33b96a-b479-47a4-a006-eb62718128cc Change-Id: I221c04a6626a39449405387343cdc43e9f02dee1 Reviewed-on: https://gerrit.libreoffice.org/35587 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
Diffstat (limited to 'vcl/source/gdi')
-rw-r--r--vcl/source/gdi/print3.cxx28
1 files changed, 18 insertions, 10 deletions
diff --git a/vcl/source/gdi/print3.cxx b/vcl/source/gdi/print3.cxx
index 63da93c899b2..28ebd80b9473 100644
--- a/vcl/source/gdi/print3.cxx
+++ b/vcl/source/gdi/print3.cxx
@@ -798,14 +798,18 @@ void PrinterController::resetPrinterOptions( bool i_bFileOutput )
bool PrinterController::setupPrinter( vcl::Window* i_pParent )
{
bool bRet = false;
- if( mpImplData->mxPrinter.get() )
+
+ // Important to hold printer alive while doing setup etc.
+ VclPtr< Printer > xPrinter = mpImplData->mxPrinter;
+
+ if( xPrinter.get() )
{
- mpImplData->mxPrinter->Push();
- mpImplData->mxPrinter->SetMapMode(MapMode(MapUnit::Map100thMM));
+ xPrinter->Push();
+ xPrinter->SetMapMode(MapMode(MapUnit::Map100thMM));
// get current data
- Size aPaperSize(mpImplData->mxPrinter->GetPaperSize());
- sal_uInt16 nPaperBin = mpImplData->mxPrinter->GetPaperBin();
+ Size aPaperSize(xPrinter->GetPaperSize());
+ sal_uInt16 nPaperBin = xPrinter->GetPaperBin();
// reset paper size back to last configured size, not
// whatever happens to be the current page
@@ -817,8 +821,12 @@ bool PrinterController::setupPrinter( vcl::Window* i_pParent )
}
// call driver setup
- bRet = mpImplData->mxPrinter->Setup( i_pParent, getPapersizeFromSetup() );
- Size aNewPaperSize(mpImplData->mxPrinter->GetPaperSize());
+ bRet = xPrinter->Setup( i_pParent, getPapersizeFromSetup() );
+ SAL_WARN_IF(xPrinter != mpImplData->mxPrinter, "vcl.gdi",
+ "Printer changed underneath us during setup");
+ xPrinter = mpImplData->mxPrinter;
+
+ Size aNewPaperSize(xPrinter->GetPaperSize());
if (bRet)
{
bool bInvalidateCache = false;
@@ -832,7 +840,7 @@ bool PrinterController::setupPrinter( vcl::Window* i_pParent )
}
// was bin overridden ? if so we need to take action
- sal_uInt16 nNewPaperBin = mpImplData->mxPrinter->GetPaperBin();
+ sal_uInt16 nNewPaperBin = xPrinter->GetPaperBin();
if (nNewPaperBin != nPaperBin)
{
mpImplData->mnFixedPaperBin = nNewPaperBin;
@@ -848,9 +856,9 @@ bool PrinterController::setupPrinter( vcl::Window* i_pParent )
{
//restore to whatever it was before we entered this method
if (aPaperSize != aNewPaperSize)
- mpImplData->mxPrinter->SetPaperSizeUser(aPaperSize, !mpImplData->isFixedPageSize());
+ xPrinter->SetPaperSizeUser(aPaperSize, !mpImplData->isFixedPageSize());
}
- mpImplData->mxPrinter->Pop();
+ xPrinter->Pop();
}
return bRet;
}