include/vcl/virdev.hxx | 3 ++- vcl/headless/svpinst.cxx | 4 ++-- vcl/inc/headless/svpinst.hxx | 3 ++- vcl/inc/osx/salinst.h | 3 ++- vcl/inc/salinst.hxx | 3 ++- vcl/inc/unx/gtk/gtkinst.hxx | 3 ++- vcl/inc/unx/saldata.hxx | 4 ++-- vcl/inc/unx/salinst.h | 5 +++-- vcl/inc/win/salinst.h | 3 ++- vcl/qt5/Qt5Instance.cxx | 11 ++++++----- vcl/qt5/Qt5Instance.hxx | 2 +- vcl/quartz/salvd.cxx | 12 ++++++------ vcl/source/gdi/virdev.cxx | 20 +++++++------------- vcl/unx/generic/app/saldata.cxx | 5 ++--- vcl/unx/generic/gdi/salvd.cxx | 8 ++++---- vcl/unx/gtk/gtkinst.cxx | 4 ++-- vcl/win/gdi/salvd.cxx | 4 ++-- 17 files changed, 49 insertions(+), 48 deletions(-)
New commits: commit dbb1dbe7a741415acf1132a29aba7cff5dfe638c Author: Noel Grandin <noel.gran...@collabora.co.uk> Date: Mon Apr 23 15:23:08 2018 +0200 loplugin:useuniqueptr in X11SalData Change-Id: I61a6d5cc5690a2899986ec831655e480a1f414d1 Reviewed-on: https://gerrit.libreoffice.org/53360 Tested-by: Jenkins <c...@libreoffice.org> Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/vcl/inc/unx/saldata.hxx b/vcl/inc/unx/saldata.hxx index 6a7902dbf444..eed9619608ed 100644 --- a/vcl/inc/unx/saldata.hxx +++ b/vcl/inc/unx/saldata.hxx @@ -56,7 +56,7 @@ class VCLPLUG_GEN_PUBLIC X11SalData : public GenericUnixSalData XIOErrorHandler m_aOrigXIOErrorHandler; protected: - SalXLib *pXLib_; + std::unique_ptr<SalXLib> pXLib_; public: X11SalData( GenericUnixSalDataType t, SalInstance *pInstance ); @@ -70,7 +70,7 @@ public: void DeleteDisplay(); // for shutdown - SalXLib* GetLib() const { return pXLib_; } + SalXLib* GetLib() const { return pXLib_.get(); } static void Timeout(); diff --git a/vcl/unx/generic/app/saldata.cxx b/vcl/unx/generic/app/saldata.cxx index 3a87ca9d0e8b..9fb0aa5c799a 100644 --- a/vcl/unx/generic/app/saldata.cxx +++ b/vcl/unx/generic/app/saldata.cxx @@ -270,13 +270,12 @@ void X11SalData::DeleteDisplay() { delete GetDisplay(); SetDisplay( nullptr ); - delete pXLib_; - pXLib_ = nullptr; + pXLib_.reset(); } void X11SalData::Init() { - pXLib_ = new SalXLib(); + pXLib_.reset(new SalXLib()); pXLib_->Init(); } commit 182197448fc206649324fa15cf5aeaf7d01723ed Author: Noel Grandin <noel.gran...@collabora.co.uk> Date: Mon Apr 23 14:16:36 2018 +0200 loplugin:useuniqueptr in VirtualDevice Change-Id: I7c70f9c590dd63cca1dce16ce184fc7e14922de2 Reviewed-on: https://gerrit.libreoffice.org/53353 Tested-by: Jenkins <c...@libreoffice.org> Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/include/vcl/virdev.hxx b/include/vcl/virdev.hxx index cf7c82140392..3895661649d8 100644 --- a/include/vcl/virdev.hxx +++ b/include/vcl/virdev.hxx @@ -23,6 +23,7 @@ #include <vcl/dllapi.h> #include <vcl/salgtype.hxx> #include <vcl/outdev.hxx> +#include <memory> class SalVirtualDevice; @@ -43,7 +44,7 @@ public: }; private: - SalVirtualDevice* mpVirDev; + std::unique_ptr<SalVirtualDevice> mpVirDev; VclPtr<VirtualDevice> mpPrev; VclPtr<VirtualDevice> mpNext; sal_uInt16 mnBitCount; diff --git a/vcl/headless/svpinst.cxx b/vcl/headless/svpinst.cxx index 664547a69a52..1128f0d61ee6 100644 --- a/vcl/headless/svpinst.cxx +++ b/vcl/headless/svpinst.cxx @@ -236,14 +236,14 @@ void SvpSalInstance::DestroyObject( SalObject* pObject ) #ifndef IOS -SalVirtualDevice* SvpSalInstance::CreateVirtualDevice( SalGraphics* pGraphics, +std::unique_ptr<SalVirtualDevice> SvpSalInstance::CreateVirtualDevice( SalGraphics* pGraphics, long &nDX, long &nDY, DeviceFormat eFormat, const SystemGraphicsData* /* pData */ ) { SvpSalGraphics *pSvpSalGraphics = dynamic_cast<SvpSalGraphics*>(pGraphics); assert(pSvpSalGraphics); - SvpSalVirtualDevice* pNew = new SvpSalVirtualDevice(eFormat, pSvpSalGraphics->getSurface()); + std::unique_ptr<SalVirtualDevice> pNew(new SvpSalVirtualDevice(eFormat, pSvpSalGraphics->getSurface())); pNew->SetSize( nDX, nDY ); return pNew; } diff --git a/vcl/inc/headless/svpinst.hxx b/vcl/inc/headless/svpinst.hxx index d370d67b8075..9eef8cdae6f3 100644 --- a/vcl/inc/headless/svpinst.hxx +++ b/vcl/inc/headless/svpinst.hxx @@ -139,7 +139,8 @@ public: // nDX and nDY in Pixel // nBitCount: 0 == Default(=as window) / 1 == Mono // pData allows for using a system dependent graphics or device context - virtual SalVirtualDevice* CreateVirtualDevice( SalGraphics* pGraphics, + virtual std::unique_ptr<SalVirtualDevice> + CreateVirtualDevice( SalGraphics* pGraphics, long &nDX, long &nDY, DeviceFormat eFormat, const SystemGraphicsData *pData = nullptr ) override; diff --git a/vcl/inc/osx/salinst.h b/vcl/inc/osx/salinst.h index f96eefaa8950..4bb86ea271db 100644 --- a/vcl/inc/osx/salinst.h +++ b/vcl/inc/osx/salinst.h @@ -96,7 +96,8 @@ public: virtual SalObject* CreateObject( SalFrame* pParent, SystemWindowData* pWindowData, bool bShow ) override; virtual void DestroyObject( SalObject* pObject ) override; - virtual SalVirtualDevice* CreateVirtualDevice( SalGraphics* pGraphics, + virtual std::unique_ptr<SalVirtualDevice> + CreateVirtualDevice( SalGraphics* pGraphics, long &nDX, long &nDY, DeviceFormat eFormat, const SystemGraphicsData *pData = nullptr ) override; diff --git a/vcl/inc/salinst.hxx b/vcl/inc/salinst.hxx index 30bf126361e8..98583ac68c6e 100644 --- a/vcl/inc/salinst.hxx +++ b/vcl/inc/salinst.hxx @@ -33,6 +33,7 @@ #include <com/sun/star/uno/XComponentContext.hpp> #include <com/sun/star/ui/dialogs/XFilePicker2.hpp> #include <com/sun/star/ui/dialogs/XFolderPicker2.hpp> +#include <memory> namespace com { namespace sun { @@ -104,7 +105,7 @@ public: // pData allows for using a system dependent graphics or device context, // if a system context is passed in nDX and nDY are updated to reflect // its size; otherwise these remain unchanged. - virtual SalVirtualDevice* + virtual std::unique_ptr<SalVirtualDevice> CreateVirtualDevice( SalGraphics* pGraphics, long &rDX, long &rDY, DeviceFormat eFormat, const SystemGraphicsData *pData = nullptr ) = 0; diff --git a/vcl/inc/unx/gtk/gtkinst.hxx b/vcl/inc/unx/gtk/gtkinst.hxx index e4cf68981392..62cf55d20ce3 100644 --- a/vcl/inc/unx/gtk/gtkinst.hxx +++ b/vcl/inc/unx/gtk/gtkinst.hxx @@ -204,7 +204,8 @@ public: virtual void DestroyMenuItem( SalMenuItem* pItem ) override; virtual SalTimer* CreateSalTimer() override; virtual void AddToRecentDocumentList(const OUString& rFileUrl, const OUString& rMimeType, const OUString& rDocumentService) override; - virtual SalVirtualDevice* CreateVirtualDevice( SalGraphics*, + virtual std::unique_ptr<SalVirtualDevice> + CreateVirtualDevice( SalGraphics*, long &nDX, long &nDY, DeviceFormat eFormat, const SystemGraphicsData* = nullptr ) override; diff --git a/vcl/inc/unx/salinst.h b/vcl/inc/unx/salinst.h index 2aed86924b68..a35c2755b5d8 100644 --- a/vcl/inc/unx/salinst.h +++ b/vcl/inc/unx/salinst.h @@ -58,10 +58,11 @@ public: virtual void DestroyObject( SalObject* pObject ) override; /// Gtk vclplug needs to pass GtkSalGraphics to X11SalVirtualDevice, so create it, and pass as pNewGraphics. - static SalVirtualDevice* CreateX11VirtualDevice(SalGraphics const * pGraphics, long &nDX, long &nDY, + static std::unique_ptr<SalVirtualDevice> CreateX11VirtualDevice(SalGraphics const * pGraphics, long &nDX, long &nDY, DeviceFormat eFormat, const SystemGraphicsData* pData, X11SalGraphics* pNewGraphics); - virtual SalVirtualDevice* CreateVirtualDevice( SalGraphics* pGraphics, + virtual std::unique_ptr<SalVirtualDevice> + CreateVirtualDevice( SalGraphics* pGraphics, long &nDX, long &nDY, DeviceFormat eFormat, const SystemGraphicsData *pData = nullptr ) override; virtual void PostPrintersChanged() override; diff --git a/vcl/inc/win/salinst.h b/vcl/inc/win/salinst.h index 9f5dbdf955b1..43902c065324 100644 --- a/vcl/inc/win/salinst.h +++ b/vcl/inc/win/salinst.h @@ -50,7 +50,8 @@ public: virtual void DestroyFrame( SalFrame* pFrame ) override; virtual SalObject* CreateObject( SalFrame* pParent, SystemWindowData* pWindowData, bool bShow ) override; virtual void DestroyObject( SalObject* pObject ) override; - virtual SalVirtualDevice* CreateVirtualDevice( SalGraphics* pGraphics, + virtual std::unique_ptr<SalVirtualDevice> + CreateVirtualDevice( SalGraphics* pGraphics, long &nDX, long &nDY, DeviceFormat eFormat, const SystemGraphicsData *pData = nullptr ) override; virtual SalInfoPrinter* CreateInfoPrinter( SalPrinterQueueInfo* pQueueInfo, diff --git a/vcl/qt5/Qt5Instance.cxx b/vcl/qt5/Qt5Instance.cxx index 7eb734195756..f0474917a149 100644 --- a/vcl/qt5/Qt5Instance.cxx +++ b/vcl/qt5/Qt5Instance.cxx @@ -84,21 +84,22 @@ SalObject* Qt5Instance::CreateObject(SalFrame* pParent, SystemWindowData*, bool void Qt5Instance::DestroyObject(SalObject* pObject) { delete pObject; } -SalVirtualDevice* Qt5Instance::CreateVirtualDevice(SalGraphics* pGraphics, long& nDX, long& nDY, - DeviceFormat eFormat, - const SystemGraphicsData* /* pData */) +std::unique_ptr<SalVirtualDevice> +Qt5Instance::CreateVirtualDevice(SalGraphics* pGraphics, long& nDX, long& nDY, DeviceFormat eFormat, + const SystemGraphicsData* /* pData */) { if (m_bUseCairo) { SvpSalGraphics* pSvpSalGraphics = dynamic_cast<SvpSalGraphics*>(pGraphics); assert(pSvpSalGraphics); - SvpSalVirtualDevice* pVD = new SvpSalVirtualDevice(eFormat, pSvpSalGraphics->getSurface()); + std::unique_ptr<SalVirtualDevice> pVD( + new SvpSalVirtualDevice(eFormat, pSvpSalGraphics->getSurface())); pVD->SetSize(nDX, nDY); return pVD; } else { - Qt5VirtualDevice* pVD = new Qt5VirtualDevice(eFormat, 1); + std::unique_ptr<SalVirtualDevice>(new Qt5VirtualDevice(eFormat, 1)); pVD->SetSize(nDX, nDY); return pVD; } diff --git a/vcl/qt5/Qt5Instance.hxx b/vcl/qt5/Qt5Instance.hxx index 22005d91e978..79d3fb58a5f8 100644 --- a/vcl/qt5/Qt5Instance.hxx +++ b/vcl/qt5/Qt5Instance.hxx @@ -63,7 +63,7 @@ public: bool bShow) override; virtual void DestroyObject(SalObject* pObject) override; - virtual SalVirtualDevice* + virtual std::unique_ptr<SalVirtualDevice> CreateVirtualDevice(SalGraphics* pGraphics, long& nDX, long& nDY, DeviceFormat eFormat, const SystemGraphicsData* pData = nullptr) override; diff --git a/vcl/quartz/salvd.cxx b/vcl/quartz/salvd.cxx index 3d9d700cb4d9..03f37fe67366 100644 --- a/vcl/quartz/salvd.cxx +++ b/vcl/quartz/salvd.cxx @@ -36,7 +36,7 @@ #include <quartz/salvd.h> #include <quartz/utils.h> -SalVirtualDevice* AquaSalInstance::CreateVirtualDevice( SalGraphics* pGraphics, +std::unique_ptr<SalVirtualDevice> AquaSalInstance::CreateVirtualDevice( SalGraphics* pGraphics, long &nDX, long &nDY, DeviceFormat eFormat, const SystemGraphicsData *pData ) @@ -47,18 +47,18 @@ SalVirtualDevice* AquaSalInstance::CreateVirtualDevice( SalGraphics* pGraphics, #ifdef IOS if( pData ) { - return new AquaSalVirtualDevice( static_cast< AquaSalGraphics* >( pGraphics ), - nDX, nDY, eFormat, pData ); + return std::unique_ptr<SalVirtualDevice>(new AquaSalVirtualDevice( static_cast< AquaSalGraphics* >( pGraphics ), + nDX, nDY, eFormat, pData )); } else { - AquaSalVirtualDevice* pNew = new AquaSalVirtualDevice( NULL, nDX, nDY, eFormat, NULL ); + std::unique_ptr<SalVirtualDevice> pNew(new AquaSalVirtualDevice( NULL, nDX, nDY, eFormat, NULL )); pNew->SetSize( nDX, nDY ); return pNew; } #else - return new AquaSalVirtualDevice( static_cast< AquaSalGraphics* >( pGraphics ), - nDX, nDY, eFormat, pData ); + return std::unique_ptr<SalVirtualDevice>(new AquaSalVirtualDevice( static_cast< AquaSalGraphics* >( pGraphics ), + nDX, nDY, eFormat, pData )); #endif } diff --git a/vcl/source/gdi/virdev.cxx b/vcl/source/gdi/virdev.cxx index 9ab205f983c9..8972d83c23c8 100644 --- a/vcl/source/gdi/virdev.cxx +++ b/vcl/source/gdi/virdev.cxx @@ -198,8 +198,7 @@ void VirtualDevice::ImplInitVirDev( const OutputDevice* pOutDev, } VirtualDevice::VirtualDevice(DeviceFormat eFormat) -: mpVirDev( nullptr ), - meRefDevMode( RefDevMode::NONE ), +: meRefDevMode( RefDevMode::NONE ), mbForceZeroExtleadBug( false ) { SAL_INFO( "vcl.virdev", "VirtualDevice::VirtualDevice( " << static_cast<int>(eFormat) << " )" ); @@ -208,8 +207,7 @@ VirtualDevice::VirtualDevice(DeviceFormat eFormat) } VirtualDevice::VirtualDevice(const OutputDevice& rCompDev, DeviceFormat eFormat) - : mpVirDev( nullptr ), - meRefDevMode( RefDevMode::NONE ), + : meRefDevMode( RefDevMode::NONE ), mbForceZeroExtleadBug( false ) { SAL_INFO( "vcl.virdev", "VirtualDevice::VirtualDevice( " << static_cast<int>(eFormat) << " )" ); @@ -218,8 +216,7 @@ VirtualDevice::VirtualDevice(const OutputDevice& rCompDev, DeviceFormat eFormat) } VirtualDevice::VirtualDevice(const OutputDevice& rCompDev, DeviceFormat eFormat, DeviceFormat eAlphaFormat) - : mpVirDev( nullptr ) - , meRefDevMode( RefDevMode::NONE ) + : meRefDevMode( RefDevMode::NONE ) , mbForceZeroExtleadBug( false ) { SAL_INFO( "vcl.virdev", @@ -233,8 +230,7 @@ VirtualDevice::VirtualDevice(const OutputDevice& rCompDev, DeviceFormat eFormat, VirtualDevice::VirtualDevice(const SystemGraphicsData *pData, const Size &rSize, DeviceFormat eFormat) -: mpVirDev( nullptr ), - meRefDevMode( RefDevMode::NONE ), +: meRefDevMode( RefDevMode::NONE ), mbForceZeroExtleadBug( false ) { SAL_INFO( "vcl.virdev", "VirtualDevice::VirtualDevice( " << static_cast<int>(eFormat) << " )" ); @@ -257,7 +253,7 @@ void VirtualDevice::dispose() ReleaseGraphics(); - delete mpVirDev; + mpVirDev.reset(); // remove this VirtualDevice from the double-linked global list if( mpPrev ) @@ -316,7 +312,7 @@ bool VirtualDevice::InnerImplSetOutputSizePixel( const Size& rNewSize, bool bEra } else { - SalVirtualDevice* pNewVirDev; + std::unique_ptr<SalVirtualDevice> pNewVirDev; ImplSVData* pSVData = ImplGetSVData(); // we need a graphics @@ -346,8 +342,7 @@ bool VirtualDevice::InnerImplSetOutputSizePixel( const Size& rNewSize, bool bEra pGraphics->CopyBits( aPosAry, mpGraphics, this, this ); pNewVirDev->ReleaseGraphics( pGraphics ); ReleaseGraphics(); - delete mpVirDev; - mpVirDev = pNewVirDev; + mpVirDev = std::move(pNewVirDev); mnOutWidth = rNewSize.Width(); mnOutHeight = rNewSize.Height(); bRet = true; @@ -355,7 +350,6 @@ bool VirtualDevice::InnerImplSetOutputSizePixel( const Size& rNewSize, bool bEra else { bRet = false; - delete pNewVirDev; } } else diff --git a/vcl/unx/generic/gdi/salvd.cxx b/vcl/unx/generic/gdi/salvd.cxx index 3be1449de90f..3bbe0fde016b 100644 --- a/vcl/unx/generic/gdi/salvd.cxx +++ b/vcl/unx/generic/gdi/salvd.cxx @@ -35,18 +35,18 @@ #include <vcl/opengl/OpenGLHelper.hxx> #include <opengl/x11/salvd.hxx> -SalVirtualDevice* X11SalInstance::CreateX11VirtualDevice(SalGraphics const * pGraphics, +std::unique_ptr<SalVirtualDevice> X11SalInstance::CreateX11VirtualDevice(SalGraphics const * pGraphics, long &nDX, long &nDY, DeviceFormat eFormat, const SystemGraphicsData *pData, X11SalGraphics* pNewGraphics) { assert(pNewGraphics); if (OpenGLHelper::isVCLOpenGLEnabled()) - return new X11OpenGLSalVirtualDevice( pGraphics, nDX, nDY, pData, pNewGraphics ); + return std::unique_ptr<SalVirtualDevice>(new X11OpenGLSalVirtualDevice( pGraphics, nDX, nDY, pData, pNewGraphics )); else - return new X11SalVirtualDevice(pGraphics, nDX, nDY, eFormat, pData, pNewGraphics); + return std::unique_ptr<SalVirtualDevice>(new X11SalVirtualDevice(pGraphics, nDX, nDY, eFormat, pData, pNewGraphics)); } -SalVirtualDevice* X11SalInstance::CreateVirtualDevice(SalGraphics* pGraphics, +std::unique_ptr<SalVirtualDevice> X11SalInstance::CreateVirtualDevice(SalGraphics* pGraphics, long &nDX, long &nDY, DeviceFormat eFormat, const SystemGraphicsData *pData) { return CreateX11VirtualDevice(pGraphics, nDX, nDY, eFormat, pData, new X11SalGraphics()); diff --git a/vcl/unx/gtk/gtkinst.cxx b/vcl/unx/gtk/gtkinst.cxx index dbd0d64ab32b..f7c41fff0f7d 100644 --- a/vcl/unx/gtk/gtkinst.cxx +++ b/vcl/unx/gtk/gtkinst.cxx @@ -321,7 +321,7 @@ void GtkYieldMutex::ThreadsLeave() } } -SalVirtualDevice* GtkInstance::CreateVirtualDevice( SalGraphics *pG, +std::unique_ptr<SalVirtualDevice> GtkInstance::CreateVirtualDevice( SalGraphics *pG, long &nDX, long &nDY, DeviceFormat eFormat, const SystemGraphicsData *pGd ) @@ -331,7 +331,7 @@ SalVirtualDevice* GtkInstance::CreateVirtualDevice( SalGraphics *pG, (void) pGd; SvpSalGraphics *pSvpSalGraphics = dynamic_cast<SvpSalGraphics*>(pG); assert(pSvpSalGraphics); - SvpSalVirtualDevice* pNew = new SvpSalVirtualDevice(eFormat, pSvpSalGraphics->getSurface()); + std::unique_ptr<SalVirtualDevice> pNew(new SvpSalVirtualDevice(eFormat, pSvpSalGraphics->getSurface())); pNew->SetSize( nDX, nDY ); return pNew; #else diff --git a/vcl/win/gdi/salvd.cxx b/vcl/win/gdi/salvd.cxx index 6a50509f876b..ffdac5306e26 100644 --- a/vcl/win/gdi/salvd.cxx +++ b/vcl/win/gdi/salvd.cxx @@ -70,7 +70,7 @@ HBITMAP WinSalVirtualDevice::ImplCreateVirDevBitmap(HDC hDC, long nDX, long nDY, return hBitmap; } -SalVirtualDevice* WinSalInstance::CreateVirtualDevice( SalGraphics* pSGraphics, +std::unique_ptr<SalVirtualDevice> WinSalInstance::CreateVirtualDevice( SalGraphics* pSGraphics, long &nDX, long &nDY, DeviceFormat eFormat, const SystemGraphicsData* pData ) @@ -135,7 +135,7 @@ SalVirtualDevice* WinSalInstance::CreateVirtualDevice( SalGraphics* pSGraphics, pVDev->setGraphics(pVirGraphics); - return pVDev; + return std::unique_ptr<SalVirtualDevice>(pVDev); } else { _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits