diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-04-23 15:32:29 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-04-24 15:43:50 +0200 |
commit | b9c46a57c16116ea4beef59abf0fd11b7d6d97a3 (patch) | |
tree | a04a03b2e30d7d382dce23e36ced6765dfbd2176 | |
parent | c5ad92524fa09005435179e2526ddbe796f3eafe (diff) |
loplugin:useuniqueptr in SalDisplay
Change-Id: I33cab261f107ed29e36d0093a87ffc3a2de21a54
Reviewed-on: https://gerrit.libreoffice.org/53361
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r-- | vcl/inc/unx/saldisp.hxx | 4 | ||||
-rw-r--r-- | vcl/inc/unx/wmadaptor.hxx | 2 | ||||
-rw-r--r-- | vcl/unx/generic/app/saldisp.cxx | 3 | ||||
-rw-r--r-- | vcl/unx/generic/app/wmadaptor.cxx | 16 |
4 files changed, 11 insertions, 14 deletions
diff --git a/vcl/inc/unx/saldisp.hxx b/vcl/inc/unx/saldisp.hxx index 48756f3cbfe1..a53be3692d8b 100644 --- a/vcl/inc/unx/saldisp.hxx +++ b/vcl/inc/unx/saldisp.hxx @@ -280,7 +280,7 @@ protected: KeySym nCtrlKeySym_; // first control modifier KeySym nMod1KeySym_; // first mod1 modifier - vcl_sal::WMAdaptor* m_pWMAdaptor; + std::unique_ptr<vcl_sal::WMAdaptor> m_pWMAdaptor; bool m_bXinerama; std::vector< tools::Rectangle > m_aXineramaScreens; @@ -367,7 +367,7 @@ public: SalI18N_KeyboardExtension* GetKbdExtension() const { return mpKbdExtension; } void SetKbdExtension(SalI18N_KeyboardExtension *pKbdExtension) { mpKbdExtension = pKbdExtension; } - ::vcl_sal::WMAdaptor* getWMAdaptor() const { return m_pWMAdaptor; } + ::vcl_sal::WMAdaptor* getWMAdaptor() const { return m_pWMAdaptor.get(); } bool IsXinerama() const { return m_bXinerama; } const std::vector< tools::Rectangle >& GetXineramaScreens() const { return m_aXineramaScreens; } ::Window GetRootWindow( SalX11Screen nXScreen ) const diff --git a/vcl/inc/unx/wmadaptor.hxx b/vcl/inc/unx/wmadaptor.hxx index 6f7f4caaa85c..ff76cf638987 100644 --- a/vcl/inc/unx/wmadaptor.hxx +++ b/vcl/inc/unx/wmadaptor.hxx @@ -160,7 +160,7 @@ public: /* * creates a valid WMAdaptor instance for the SalDisplay */ - static WMAdaptor* createWMAdaptor( SalDisplay* ); + static std::unique_ptr<WMAdaptor> createWMAdaptor( SalDisplay* ); /* * may return an empty string if the window manager could diff --git a/vcl/unx/generic/app/saldisp.cxx b/vcl/unx/generic/app/saldisp.cxx index da1d1723a7df..5d266828196a 100644 --- a/vcl/unx/generic/app/saldisp.cxx +++ b/vcl/unx/generic/app/saldisp.cxx @@ -321,8 +321,7 @@ void SalDisplay::doDestruct() { GenericUnixSalData *pData = GetGenericUnixSalData(); - delete m_pWMAdaptor; - m_pWMAdaptor = nullptr; + m_pWMAdaptor.reset(); X11SalBitmap::ImplDestroyCache(); X11SalGraphics::releaseGlyphPeer(); diff --git a/vcl/unx/generic/app/wmadaptor.cxx b/vcl/unx/generic/app/wmadaptor.cxx index 898931147c64..0fda5b0866c0 100644 --- a/vcl/unx/generic/app/wmadaptor.cxx +++ b/vcl/unx/generic/app/wmadaptor.cxx @@ -172,16 +172,15 @@ static int compareProtocol( const void* pLeft, const void* pRight ) } } -WMAdaptor* WMAdaptor::createWMAdaptor( SalDisplay* pSalDisplay ) +std::unique_ptr<WMAdaptor> WMAdaptor::createWMAdaptor( SalDisplay* pSalDisplay ) { - WMAdaptor* pAdaptor = nullptr; + std::unique_ptr<WMAdaptor> pAdaptor; // try a NetWM - pAdaptor = new NetWMAdaptor( pSalDisplay ); + pAdaptor.reset(new NetWMAdaptor( pSalDisplay )); if( ! pAdaptor->isValid() ) { - delete pAdaptor; - pAdaptor = nullptr; + pAdaptor.reset(); } #if OSL_DEBUG_LEVEL > 1 else @@ -191,11 +190,10 @@ WMAdaptor* WMAdaptor::createWMAdaptor( SalDisplay* pSalDisplay ) // try a GnomeWM if( ! pAdaptor ) { - pAdaptor = new GnomeWMAdaptor( pSalDisplay ); + pAdaptor.reset(new GnomeWMAdaptor( pSalDisplay )); if( ! pAdaptor->isValid() ) { - delete pAdaptor; - pAdaptor = nullptr; + pAdaptor.reset(); } #if OSL_DEBUG_LEVEL > 1 else @@ -204,7 +202,7 @@ WMAdaptor* WMAdaptor::createWMAdaptor( SalDisplay* pSalDisplay ) } if( ! pAdaptor ) - pAdaptor = new WMAdaptor( pSalDisplay ); + pAdaptor.reset(new WMAdaptor( pSalDisplay )); #if OSL_DEBUG_LEVEL > 1 fprintf(stderr, "Window Manager's name is \"%s\"\n", |