diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-01-10 15:36:33 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-01-11 07:40:35 +0100 |
commit | eefd133d901a3f701cfaa8bbc04c7c99ef56161d (patch) | |
tree | 0e0e29d8ec950f2a360add18de8f84fd113ccf6b /vcl | |
parent | b27fee9e0ebb445ce82baeade3b249807dca392b (diff) |
loplugin:useuniqueptr in ImplAccelManager
Change-Id: Ie7968fc709255b07a7045d50aa7641aa4fa70098
Reviewed-on: https://gerrit.libreoffice.org/47728
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/inc/accmgr.hxx | 9 | ||||
-rw-r--r-- | vcl/source/window/accmgr.cxx | 11 |
2 files changed, 7 insertions, 13 deletions
diff --git a/vcl/inc/accmgr.hxx b/vcl/inc/accmgr.hxx index 5cf64501cd8e..1e57ed44dd07 100644 --- a/vcl/inc/accmgr.hxx +++ b/vcl/inc/accmgr.hxx @@ -21,24 +21,21 @@ #define INCLUDED_VCL_INC_ACCMGR_HXX #include <vector> +#include <memory> #include <vcl/keycod.hxx> class Accelerator; -typedef ::std::vector< Accelerator* > ImplAccelList; - class ImplAccelManager { private: - ImplAccelList* mpAccelList; - ImplAccelList* mpSequenceList; + std::unique_ptr<std::vector< Accelerator* >> mpAccelList; + std::unique_ptr<std::vector< Accelerator* >> mpSequenceList; public: ImplAccelManager() { - mpAccelList = nullptr; - mpSequenceList = nullptr; } ~ImplAccelManager(); diff --git a/vcl/source/window/accmgr.cxx b/vcl/source/window/accmgr.cxx index d357988f8d08..7ea18d664d16 100644 --- a/vcl/source/window/accmgr.cxx +++ b/vcl/source/window/accmgr.cxx @@ -24,14 +24,12 @@ ImplAccelManager::~ImplAccelManager() { - delete mpAccelList; - delete mpSequenceList; } bool ImplAccelManager::InsertAccel( Accelerator* pAccel ) { if ( !mpAccelList ) { - mpAccelList = new ImplAccelList; + mpAccelList.reset( new std::vector< Accelerator* > ); } else { for (Accelerator* i : *mpAccelList) { if ( i == pAccel ) { @@ -68,7 +66,7 @@ void ImplAccelManager::RemoveAccel( Accelerator const * pAccel ) } // throw it away - for ( ImplAccelList::iterator it = mpAccelList->begin(); + for ( auto it = mpAccelList->begin(); it != mpAccelList->end(); ++it ) { @@ -91,8 +89,7 @@ void ImplAccelManager::EndSequence() } // delete sequence-list - delete mpSequenceList; - mpSequenceList = nullptr; + mpSequenceList.reset(); } bool ImplAccelManager::IsAccelKey( const vcl::KeyCode& rKeyCode ) @@ -193,7 +190,7 @@ bool ImplAccelManager::IsAccelKey( const vcl::KeyCode& rKeyCode ) { // create sequence list - mpSequenceList = new ImplAccelList; + mpSequenceList.reset( new std::vector< Accelerator* > ); mpSequenceList->insert( mpSequenceList->begin(), pAccel ); mpSequenceList->insert( mpSequenceList->begin(), pNextAccel ); |