protect more printer code-paths.

Change-Id: Ic5bc5c3325b460cba0d95484454c9bb826684890
This commit is contained in:
Michael Meeks
2015-03-20 23:08:41 +00:00
parent a8dc965511
commit c612c3b0ae
6 changed files with 18 additions and 12 deletions

View File

@@ -51,7 +51,9 @@ DocShell::DocShell()
} }
DocShell::~DocShell() DocShell::~DocShell()
{ } {
pPrinter.disposeAndClear();
}
SfxPrinter* DocShell::GetPrinter( bool bCreate ) SfxPrinter* DocShell::GetPrinter( bool bCreate )
{ {

View File

@@ -637,7 +637,7 @@ Printer* SfxViewShell::GetActivePrinter() const
void SfxViewShell::ExecPrint_Impl( SfxRequest &rReq ) void SfxViewShell::ExecPrint_Impl( SfxRequest &rReq )
{ {
sal_uInt16 nDialogRet = RET_CANCEL; sal_uInt16 nDialogRet = RET_CANCEL;
SfxPrinter* pPrinter = 0; VclPtr<SfxPrinter> pPrinter;
bool bSilent = false; bool bSilent = false;
// does the function have been called by the user interface or by an API call // does the function have been called by the user interface or by an API call
@@ -774,7 +774,7 @@ void SfxViewShell::ExecPrint_Impl( SfxRequest &rReq )
// if printer is unknown, it can't be used - now printer from document will be used // if printer is unknown, it can't be used - now printer from document will be used
if ( !pPrinter->IsKnown() ) if ( !pPrinter->IsKnown() )
DELETEZ(pPrinter); pPrinter.disposeAndClear();
} }
if ( SID_PRINTER_NAME == nId ) if ( SID_PRINTER_NAME == nId )
@@ -816,7 +816,7 @@ void SfxViewShell::ExecPrint_Impl( SfxRequest &rReq )
if ( !bIsAPI ) if ( !bIsAPI )
{ {
// PrinterDialog needs a temporary printer // PrinterDialog needs a temporary printer
SfxPrinter* pDlgPrinter = pPrinter->Clone(); VclPtr<SfxPrinter> pDlgPrinter = pPrinter->Clone();
nDialogRet = 0; nDialogRet = 0;
// execute PrinterSetupDialog // execute PrinterSetupDialog
@@ -868,13 +868,12 @@ void SfxViewShell::ExecPrint_Impl( SfxRequest &rReq )
// forget new printer, it was taken over (as pPrinter) or deleted // forget new printer, it was taken over (as pPrinter) or deleted
pDlgPrinter = NULL; pDlgPrinter = NULL;
} }
else else
{ {
// PrinterDialog is used to transfer information on printing, // PrinterDialog is used to transfer information on printing,
// so it will only be deleted here if dialog was cancelled // so it will only be deleted here if dialog was cancelled
DELETEZ( pDlgPrinter ); pDlgPrinter.disposeAndClear();
rReq.Ignore(); rReq.Ignore();
} }
} }

View File

@@ -642,7 +642,7 @@ void SmModel::_setPropertyValues(const PropertyMapEntry** ppEntries, const Any*
SfxItemSet *pItemSet = new SfxItemSet( pDocSh->GetPool(), nRange ); SfxItemSet *pItemSet = new SfxItemSet( pDocSh->GetPool(), nRange );
SmModule *pp = SM_MOD(); SmModule *pp = SM_MOD();
pp->GetConfig()->ConfigToItemSet(*pItemSet); pp->GetConfig()->ConfigToItemSet(*pItemSet);
SfxPrinter *pPrinter = SfxPrinter::Create ( aStream, pItemSet ); VclPtr<SfxPrinter> pPrinter = SfxPrinter::Create ( aStream, pItemSet );
pDocSh->SetPrinter( pPrinter ); pDocSh->SetPrinter( pPrinter );
} }

View File

@@ -53,8 +53,9 @@ void ImplFreePrnDlgListBox( ListBox* pBox, bool bClear )
Printer* ImplPrnDlgListBoxSelect( ListBox* pBox, PushButton* pPropBtn, Printer* ImplPrnDlgListBoxSelect( ListBox* pBox, PushButton* pPropBtn,
Printer* pPrinter, Printer* pTempPrinter ) Printer* pPrinter, Printer* pTempPrinterIn )
{ {
VclPtr<Printer> pTempPrinter( pTempPrinterIn );
if ( pBox->GetSelectEntryPos() != LISTBOX_ENTRY_NOTFOUND ) if ( pBox->GetSelectEntryPos() != LISTBOX_ENTRY_NOTFOUND )
{ {
const QueueInfo* pInfo = Printer::GetQueueInfo( pBox->GetSelectEntry(), true ); const QueueInfo* pInfo = Printer::GetQueueInfo( pBox->GetSelectEntry(), true );
@@ -73,7 +74,7 @@ Printer* ImplPrnDlgListBoxSelect( ListBox* pBox, PushButton* pPropBtn,
if ( (pTempPrinter->GetName() != pInfo->GetPrinterName()) || if ( (pTempPrinter->GetName() != pInfo->GetPrinterName()) ||
(pTempPrinter->GetDriverName() != pInfo->GetDriver()) ) (pTempPrinter->GetDriverName() != pInfo->GetDriver()) )
{ {
VclPtr<Printer>(pTempPrinter).disposeAndClear(); pTempPrinter.disposeAndClear();
pTempPrinter = new Printer( *pInfo ); pTempPrinter = new Printer( *pInfo );
} }
} }
@@ -91,8 +92,9 @@ Printer* ImplPrnDlgListBoxSelect( ListBox* pBox, PushButton* pPropBtn,
Printer* ImplPrnDlgUpdatePrinter( Printer* pPrinter, Printer* pTempPrinter ) Printer* ImplPrnDlgUpdatePrinter( Printer* pPrinter, Printer* pTempPrinterIn )
{ {
VclPtr<Printer> pTempPrinter( pTempPrinterIn );
OUString aPrnName; OUString aPrnName;
if ( pTempPrinter ) if ( pTempPrinter )
aPrnName = pTempPrinter->GetName(); aPrnName = pTempPrinter->GetName();
@@ -101,7 +103,7 @@ Printer* ImplPrnDlgUpdatePrinter( Printer* pPrinter, Printer* pTempPrinter )
if ( ! Printer::GetQueueInfo( aPrnName, false ) ) if ( ! Printer::GetQueueInfo( aPrnName, false ) )
{ {
VclPtr<Printer>(pTempPrinter).disposeAndClear(); pTempPrinter.disposeAndClear();
pTempPrinter = new Printer; pTempPrinter = new Printer;
} }

View File

@@ -425,7 +425,7 @@ void SwXDocumentSettings::_setSingleValue( const comphelper::PropertyInfo & rInf
0 0
}; };
SfxItemSet *pItemSet = new SfxItemSet( mpDoc->GetAttrPool(), nRange ); SfxItemSet *pItemSet = new SfxItemSet( mpDoc->GetAttrPool(), nRange );
SfxPrinter *pPrinter = SfxPrinter::Create ( aStream, pItemSet ); VclPtr<SfxPrinter> pPrinter = SfxPrinter::Create ( aStream, pItemSet );
// set printer only once; in _postSetValues // set printer only once; in _postSetValues
mpPrinter.disposeAndClear(); mpPrinter.disposeAndClear();

View File

@@ -343,6 +343,9 @@ inline void ImplCalcMapResolution( const MapMode& rMapMode,
// #i75163# // #i75163#
void OutputDevice::ImplInvalidateViewTransform() void OutputDevice::ImplInvalidateViewTransform()
{ {
if(!mpOutDevData)
return;
if(mpOutDevData->mpViewTransform) if(mpOutDevData->mpViewTransform)
{ {
delete mpOutDevData->mpViewTransform; delete mpOutDevData->mpViewTransform;