[Libreoffice-commits] core.git: include/vcl vcl/headless vcl/inc vcl/ios vcl/osx vcl/qt5 vcl/source vcl/unx vcl/win
Noel Grandin
noel.grandin at collabora.co.uk
Sat Jun 9 11:12:08 UTC 2018
include/vcl/print.hxx | 2 +-
vcl/headless/svpprn.cxx | 9 ++-------
vcl/inc/headless/svpinst.hxx | 3 +--
vcl/inc/osx/salinst.h | 3 +--
vcl/inc/qt5/Qt5Instance.hxx | 3 +--
vcl/inc/salinst.hxx | 3 +--
vcl/inc/unx/geninst.h | 3 +--
vcl/inc/unx/gtk/gtkinst.hxx | 2 +-
vcl/inc/win/salinst.h | 3 +--
vcl/ios/dummies.cxx | 18 ++++--------------
vcl/osx/salinst.cxx | 9 ++-------
vcl/qt5/Qt5Instance_Print.cxx | 6 ++----
vcl/source/gdi/print.cxx | 3 +--
vcl/source/gdi/print3.cxx | 11 ++++-------
vcl/unx/generic/print/genprnpsp.cxx | 9 ++-------
vcl/unx/gtk/gtkinst.cxx | 4 ++--
vcl/win/gdi/salprn.cxx | 9 ++-------
17 files changed, 29 insertions(+), 71 deletions(-)
New commits:
commit 6d008c9e1dbe4240a10c8789860dc30b0cb0b2d5
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date: Fri Jun 8 13:32:57 2018 +0200
hold and return SalPrinter with std::unique_ptr
and remove DestroyPrinter, doesn't not anything beyond delete'ing the
object
Change-Id: I25e14b962e65a0e131fae3ff5771c82920a4e375
Reviewed-on: https://gerrit.libreoffice.org/55498
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/include/vcl/print.hxx b/include/vcl/print.hxx
index c80b514b05df..2fe921ee1870 100644
--- a/include/vcl/print.hxx
+++ b/include/vcl/print.hxx
@@ -182,7 +182,7 @@ class VCL_DLLPUBLIC Printer : public OutputDevice
private:
SalInfoPrinter* mpInfoPrinter;
- SalPrinter* mpPrinter;
+ std::unique_ptr<SalPrinter> mpPrinter;
SalGraphics* mpJobGraphics;
VclPtr<Printer> mpPrev;
VclPtr<Printer> mpNext;
diff --git a/vcl/headless/svpprn.cxx b/vcl/headless/svpprn.cxx
index e54c01a4c437..7b661c1d58e0 100644
--- a/vcl/headless/svpprn.cxx
+++ b/vcl/headless/svpprn.cxx
@@ -188,18 +188,13 @@ void SvpSalInstance::DestroyInfoPrinter( SalInfoPrinter* pPrinter )
delete pPrinter;
}
-SalPrinter* SvpSalInstance::CreatePrinter( SalInfoPrinter* pInfoPrinter )
+std::unique_ptr<SalPrinter> SvpSalInstance::CreatePrinter( SalInfoPrinter* pInfoPrinter )
{
// create and initialize SalPrinter
SvpSalPrinter* pPrinter = new SvpSalPrinter( pInfoPrinter );
pPrinter->m_aJobData = static_cast<SvpSalInfoPrinter*>(pInfoPrinter)->m_aJobData;
- return pPrinter;
-}
-
-void SvpSalInstance::DestroyPrinter( SalPrinter* pPrinter )
-{
- delete pPrinter;
+ return std::unique_ptr<SalPrinter>(pPrinter);
}
void SvpSalInstance::GetPrinterQueueInfo( ImplPrnQueueList* pList )
diff --git a/vcl/inc/headless/svpinst.hxx b/vcl/inc/headless/svpinst.hxx
index cf9ced053c8a..a56aa408f601 100644
--- a/vcl/inc/headless/svpinst.hxx
+++ b/vcl/inc/headless/svpinst.hxx
@@ -151,8 +151,7 @@ public:
virtual SalInfoPrinter* CreateInfoPrinter( SalPrinterQueueInfo* pQueueInfo,
ImplJobSetup* pSetupData ) override;
virtual void DestroyInfoPrinter( SalInfoPrinter* pPrinter ) override;
- virtual SalPrinter* CreatePrinter( SalInfoPrinter* pInfoPrinter ) override;
- virtual void DestroyPrinter( SalPrinter* pPrinter ) override;
+ virtual std::unique_ptr<SalPrinter> CreatePrinter( SalInfoPrinter* pInfoPrinter ) override;
virtual void GetPrinterQueueInfo( ImplPrnQueueList* pList ) override;
virtual void GetPrinterQueueState( SalPrinterQueueInfo* pInfo ) override;
diff --git a/vcl/inc/osx/salinst.h b/vcl/inc/osx/salinst.h
index 27d6266501f7..18f8630b0f27 100644
--- a/vcl/inc/osx/salinst.h
+++ b/vcl/inc/osx/salinst.h
@@ -105,8 +105,7 @@ public:
virtual SalInfoPrinter* CreateInfoPrinter( SalPrinterQueueInfo* pQueueInfo,
ImplJobSetup* pSetupData ) override;
virtual void DestroyInfoPrinter( SalInfoPrinter* pPrinter ) override;
- virtual SalPrinter* CreatePrinter( SalInfoPrinter* pInfoPrinter ) override;
- virtual void DestroyPrinter( SalPrinter* pPrinter ) override;
+ virtual std::unique_ptr<SalPrinter> CreatePrinter( SalInfoPrinter* pInfoPrinter ) override;
virtual void GetPrinterQueueInfo( ImplPrnQueueList* pList ) override;
virtual void GetPrinterQueueState( SalPrinterQueueInfo* pInfo ) override;
virtual void DeletePrinterQueueInfo( SalPrinterQueueInfo* pInfo ) override;
diff --git a/vcl/inc/qt5/Qt5Instance.hxx b/vcl/inc/qt5/Qt5Instance.hxx
index 84eff744d32b..aea3e792bfa0 100644
--- a/vcl/inc/qt5/Qt5Instance.hxx
+++ b/vcl/inc/qt5/Qt5Instance.hxx
@@ -73,8 +73,7 @@ public:
virtual SalInfoPrinter* CreateInfoPrinter(SalPrinterQueueInfo* pQueueInfo,
ImplJobSetup* pSetupData) override;
virtual void DestroyInfoPrinter(SalInfoPrinter* pPrinter) override;
- virtual SalPrinter* CreatePrinter(SalInfoPrinter* pInfoPrinter) override;
- virtual void DestroyPrinter(SalPrinter* pPrinter) override;
+ virtual std::unique_ptr<SalPrinter> CreatePrinter(SalInfoPrinter* pInfoPrinter) override;
virtual void GetPrinterQueueInfo(ImplPrnQueueList* pList) override;
virtual void GetPrinterQueueState(SalPrinterQueueInfo* pInfo) override;
virtual void DeletePrinterQueueInfo(SalPrinterQueueInfo* pInfo) override;
diff --git a/vcl/inc/salinst.hxx b/vcl/inc/salinst.hxx
index e04d849e4169..c8f330350ad4 100644
--- a/vcl/inc/salinst.hxx
+++ b/vcl/inc/salinst.hxx
@@ -117,8 +117,7 @@ public:
virtual SalInfoPrinter* CreateInfoPrinter( SalPrinterQueueInfo* pQueueInfo,
ImplJobSetup* pSetupData ) = 0;
virtual void DestroyInfoPrinter( SalInfoPrinter* pPrinter ) = 0;
- virtual SalPrinter* CreatePrinter( SalInfoPrinter* pInfoPrinter ) = 0;
- virtual void DestroyPrinter( SalPrinter* pPrinter ) = 0;
+ virtual std::unique_ptr<SalPrinter> CreatePrinter( SalInfoPrinter* pInfoPrinter ) = 0;
virtual void GetPrinterQueueInfo( ImplPrnQueueList* pList ) = 0;
virtual void GetPrinterQueueState( SalPrinterQueueInfo* pInfo ) = 0;
diff --git a/vcl/inc/unx/geninst.h b/vcl/inc/unx/geninst.h
index af97a2d9ba83..3b9b7b79ca82 100644
--- a/vcl/inc/unx/geninst.h
+++ b/vcl/inc/unx/geninst.h
@@ -60,8 +60,7 @@ public:
virtual SalInfoPrinter* CreateInfoPrinter ( SalPrinterQueueInfo* pQueueInfo,
ImplJobSetup* pSetupData ) override;
virtual void DestroyInfoPrinter ( SalInfoPrinter* pPrinter ) override;
- virtual SalPrinter* CreatePrinter ( SalInfoPrinter* pInfoPrinter ) override;
- virtual void DestroyPrinter ( SalPrinter* pPrinter ) override;
+ virtual std::unique_ptr<SalPrinter> CreatePrinter ( SalInfoPrinter* pInfoPrinter ) override;
virtual void GetPrinterQueueInfo ( ImplPrnQueueList* pList ) override;
virtual void GetPrinterQueueState ( SalPrinterQueueInfo* pInfo ) override;
virtual void DeletePrinterQueueInfo ( SalPrinterQueueInfo* pInfo ) override;
diff --git a/vcl/inc/unx/gtk/gtkinst.hxx b/vcl/inc/unx/gtk/gtkinst.hxx
index aea9e0223fe6..25d3ff020886 100644
--- a/vcl/inc/unx/gtk/gtkinst.hxx
+++ b/vcl/inc/unx/gtk/gtkinst.hxx
@@ -197,7 +197,7 @@ public:
#endif
virtual SalSystem* CreateSalSystem() override;
virtual SalInfoPrinter* CreateInfoPrinter(SalPrinterQueueInfo* pPrinterQueueInfo, ImplJobSetup* pJobSetup) override;
- virtual SalPrinter* CreatePrinter( SalInfoPrinter* pInfoPrinter ) override;
+ virtual std::unique_ptr<SalPrinter> CreatePrinter( SalInfoPrinter* pInfoPrinter ) override;
virtual SalMenu* CreateMenu( bool, Menu* ) override;
virtual void DestroyMenu( SalMenu* pMenu ) override;
virtual SalMenuItem* CreateMenuItem( const SalItemParams* ) override;
diff --git a/vcl/inc/win/salinst.h b/vcl/inc/win/salinst.h
index 77e14012b220..4274f731ee2b 100644
--- a/vcl/inc/win/salinst.h
+++ b/vcl/inc/win/salinst.h
@@ -57,8 +57,7 @@ public:
virtual SalInfoPrinter* CreateInfoPrinter( SalPrinterQueueInfo* pQueueInfo,
ImplJobSetup* pSetupData ) override;
virtual void DestroyInfoPrinter( SalInfoPrinter* pPrinter ) override;
- virtual SalPrinter* CreatePrinter( SalInfoPrinter* pInfoPrinter ) override;
- virtual void DestroyPrinter( SalPrinter* pPrinter ) override;
+ virtual std::unique_ptr<SalPrinter> CreatePrinter( SalInfoPrinter* pInfoPrinter ) override;
virtual void GetPrinterQueueInfo( ImplPrnQueueList* pList ) override;
virtual void GetPrinterQueueState( SalPrinterQueueInfo* pInfo ) override;
virtual void DeletePrinterQueueInfo( SalPrinterQueueInfo* pInfo ) override;
diff --git a/vcl/ios/dummies.cxx b/vcl/ios/dummies.cxx
index ff8991dfacfa..641b0db2d6bf 100644
--- a/vcl/ios/dummies.cxx
+++ b/vcl/ios/dummies.cxx
@@ -24,9 +24,9 @@
#include "unx/gendata.hxx"
-SalPrinter* SvpSalInstance::CreatePrinter( SalInfoPrinter* /* pInfoPrinter */ )
+std::unique_ptr<SalPrinter> SvpSalInstance::CreatePrinter( SalInfoPrinter* /* pInfoPrinter */ )
{
- return NULL;
+ return nullptr;
}
OUString SvpSalInstance::GetDefaultPrinter()
@@ -39,11 +39,6 @@ GenPspGraphics *SvpSalInstance::CreatePrintGraphics()
return NULL;
}
-void SvpSalInstance::DestroyPrinter( SalPrinter* pPrinter )
-{
- delete pPrinter;
-}
-
void SvpSalInstance::PostPrintersChanged()
{
}
@@ -72,9 +67,9 @@ void SvpSalInstance::DeletePrinterQueueInfo( SalPrinterQueueInfo* pInfo )
delete pInfo;
}
-SalPrinter* SalGenericInstance::CreatePrinter( SalInfoPrinter* /* pInfoPrinter */ )
+std::unique_ptr<SalPrinter> SalGenericInstance::CreatePrinter( SalInfoPrinter* /* pInfoPrinter */ )
{
- return NULL;
+ return nullptr;
}
OUString SalGenericInstance::GetDefaultPrinter()
@@ -82,11 +77,6 @@ OUString SalGenericInstance::GetDefaultPrinter()
return OUString();
}
-void SalGenericInstance::DestroyPrinter( SalPrinter* pPrinter )
-{
- delete pPrinter;
-}
-
void SalGenericInstance::PostPrintersChanged()
{
}
diff --git a/vcl/osx/salinst.cxx b/vcl/osx/salinst.cxx
index 43a288ebd2ed..08302f8150ed 100644
--- a/vcl/osx/salinst.cxx
+++ b/vcl/osx/salinst.cxx
@@ -795,14 +795,9 @@ void AquaSalInstance::DestroyObject( SalObject* pObject )
delete pObject;
}
-SalPrinter* AquaSalInstance::CreatePrinter( SalInfoPrinter* pInfoPrinter )
+std::unique_ptr<SalPrinter> AquaSalInstance::CreatePrinter( SalInfoPrinter* pInfoPrinter )
{
- return new AquaSalPrinter( dynamic_cast<AquaSalInfoPrinter*>(pInfoPrinter) );
-}
-
-void AquaSalInstance::DestroyPrinter( SalPrinter* pPrinter )
-{
- delete pPrinter;
+ return std::unique_ptr<SalPrinter>(new AquaSalPrinter( dynamic_cast<AquaSalInfoPrinter*>(pInfoPrinter) ));
}
void AquaSalInstance::GetPrinterQueueInfo( ImplPrnQueueList* pList )
diff --git a/vcl/qt5/Qt5Instance_Print.cxx b/vcl/qt5/Qt5Instance_Print.cxx
index a0bfed1d2f9f..e1b6bdc158c3 100644
--- a/vcl/qt5/Qt5Instance_Print.cxx
+++ b/vcl/qt5/Qt5Instance_Print.cxx
@@ -186,17 +186,15 @@ SalInfoPrinter* Qt5Instance::CreateInfoPrinter(SalPrinterQueueInfo* pQueueInfo,
void Qt5Instance::DestroyInfoPrinter(SalInfoPrinter* pPrinter) { delete pPrinter; }
-SalPrinter* Qt5Instance::CreatePrinter(SalInfoPrinter* pInfoPrinter)
+std::unique_ptr<SalPrinter> Qt5Instance::CreatePrinter(SalInfoPrinter* pInfoPrinter)
{
// create and initialize SalPrinter
Qt5Printer* pPrinter = new Qt5Printer(pInfoPrinter);
pPrinter->m_aJobData = static_cast<Qt5InfoPrinter*>(pInfoPrinter)->m_aJobData;
- return pPrinter;
+ return std::unique_ptr<SalPrinter>(pPrinter);
}
-void Qt5Instance::DestroyPrinter(SalPrinter* pPrinter) { delete pPrinter; }
-
void Qt5Instance::GetPrinterQueueInfo(ImplPrnQueueList* pList)
{
PrinterInfoManager& rManager(PrinterInfoManager::get());
diff --git a/vcl/source/gdi/print.cxx b/vcl/source/gdi/print.cxx
index ac44dcbbaf18..aeed0625d7fa 100644
--- a/vcl/source/gdi/print.cxx
+++ b/vcl/source/gdi/print.cxx
@@ -1593,8 +1593,7 @@ void Printer::EndJob()
// FIXME: Do not destroy the printer asynchronously as Win95
// can't handle destroying a printer object and printing
// at the same time
- ImplGetSVData()->mpDefInst->DestroyPrinter( mpPrinter );
- mpPrinter = nullptr;
+ mpPrinter.reset();
}
}
diff --git a/vcl/source/gdi/print3.cxx b/vcl/source/gdi/print3.cxx
index 544e07ce02d4..64d316bdd4aa 100644
--- a/vcl/source/gdi/print3.cxx
+++ b/vcl/source/gdi/print3.cxx
@@ -616,9 +616,8 @@ bool Printer::StartJob( const OUString& i_rJobName, std::shared_ptr<vcl::Printer
mnError = ImplSalPrinterErrorCodeToVCL(mpPrinter->GetErrorCode());
if ( !mnError )
mnError = PRINTER_GENERALERROR;
- pSVData->mpDefInst->DestroyPrinter( mpPrinter );
- mbPrinting = false;
- mpPrinter = nullptr;
+ mbPrinting = false;
+ mpPrinter.reset();
mbJobActive = false;
GDIMetaFile aDummyFile;
@@ -726,10 +725,8 @@ bool Printer::StartJob( const OUString& i_rJobName, std::shared_ptr<vcl::Printer
i_xController->setJobState( mnError == PRINTER_ABORT
? css::view::PrintableState_JOB_ABORTED
: css::view::PrintableState_JOB_FAILED );
- if( mpPrinter )
- pSVData->mpDefInst->DestroyPrinter( mpPrinter );
- mbPrinting = false;
- mpPrinter = nullptr;
+ mbPrinting = false;
+ mpPrinter.reset();
return false;
}
diff --git a/vcl/unx/generic/print/genprnpsp.cxx b/vcl/unx/generic/print/genprnpsp.cxx
index dc1d4ebf54cd..7a36e3196b9a 100644
--- a/vcl/unx/generic/print/genprnpsp.cxx
+++ b/vcl/unx/generic/print/genprnpsp.cxx
@@ -392,19 +392,14 @@ void SalGenericInstance::DestroyInfoPrinter( SalInfoPrinter* pPrinter )
delete pPrinter;
}
-SalPrinter* SalGenericInstance::CreatePrinter( SalInfoPrinter* pInfoPrinter )
+std::unique_ptr<SalPrinter> SalGenericInstance::CreatePrinter( SalInfoPrinter* pInfoPrinter )
{
mbPrinterInit = true;
// create and initialize SalPrinter
PspSalPrinter* pPrinter = new PspSalPrinter( pInfoPrinter );
pPrinter->m_aJobData = static_cast<PspSalInfoPrinter*>(pInfoPrinter)->m_aJobData;
- return pPrinter;
-}
-
-void SalGenericInstance::DestroyPrinter( SalPrinter* pPrinter )
-{
- delete pPrinter;
+ return std::unique_ptr<SalPrinter>(pPrinter);
}
void SalGenericInstance::GetPrinterQueueInfo( ImplPrnQueueList* pList )
diff --git a/vcl/unx/gtk/gtkinst.cxx b/vcl/unx/gtk/gtkinst.cxx
index 4e168ca6dcf2..926ef9b3f9d0 100644
--- a/vcl/unx/gtk/gtkinst.cxx
+++ b/vcl/unx/gtk/gtkinst.cxx
@@ -280,12 +280,12 @@ SalInfoPrinter* GtkInstance::CreateInfoPrinter( SalPrinterQueueInfo* pQueueInfo,
#endif
}
-SalPrinter* GtkInstance::CreatePrinter( SalInfoPrinter* pInfoPrinter )
+std::unique_ptr<SalPrinter> GtkInstance::CreatePrinter( SalInfoPrinter* pInfoPrinter )
{
EnsureInit();
#if defined ENABLE_GTK_PRINT || GTK_CHECK_VERSION(3,0,0)
mbPrinterInit = true;
- return new GtkSalPrinter( pInfoPrinter );
+ return std::unique_ptr<SalPrinter>(new GtkSalPrinter( pInfoPrinter ));
#else
return Superclass_t::CreatePrinter( pInfoPrinter );
#endif
diff --git a/vcl/win/gdi/salprn.cxx b/vcl/win/gdi/salprn.cxx
index a682f9d33f0a..0027263b5af9 100644
--- a/vcl/win/gdi/salprn.cxx
+++ b/vcl/win/gdi/salprn.cxx
@@ -1279,16 +1279,11 @@ void WinSalInfoPrinter::GetPageInfo( const ImplJobSetup*,
}
-SalPrinter* WinSalInstance::CreatePrinter( SalInfoPrinter* pInfoPrinter )
+std::unique_ptr<SalPrinter> WinSalInstance::CreatePrinter( SalInfoPrinter* pInfoPrinter )
{
WinSalPrinter* pPrinter = new WinSalPrinter;
pPrinter->mpInfoPrinter = static_cast<WinSalInfoPrinter*>(pInfoPrinter);
- return pPrinter;
-}
-
-void WinSalInstance::DestroyPrinter( SalPrinter* pPrinter )
-{
- delete pPrinter;
+ return std::unique_ptr<SalPrinter>(pPrinter);
}
BOOL CALLBACK SalPrintAbortProc( HDC hPrnDC, int /* nError */ )
More information about the Libreoffice-commits
mailing list