vcl/inc/accmgr.hxx | 9 +++------ vcl/source/window/accmgr.cxx | 11 ++++------- 2 files changed, 7 insertions(+), 13 deletions(-)
New commits: commit eefd133d901a3f701cfaa8bbc04c7c99ef56161d Author: Noel Grandin <[email protected]> Date: Wed Jan 10 15:36:33 2018 +0200 loplugin:useuniqueptr in ImplAccelManager Change-Id: Ie7968fc709255b07a7045d50aa7641aa4fa70098 Reviewed-on: https://gerrit.libreoffice.org/47728 Tested-by: Jenkins <[email protected]> Reviewed-by: Noel Grandin <[email protected]> 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 ); _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
