diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-08-23 15:15:20 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-08-24 14:33:45 +0200 |
commit | f9acc8649d4a31ddd84832124e0413d4f1fa1710 (patch) | |
tree | 843d2b4d9b5128a7b2e081aff812e5a37b19d8af /framework | |
parent | 96b07db82b4a7834246ae8acc395cd2cb355630b (diff) |
loplugin:useuniqueptr in framework
Change-Id: I89bcfaa605251912bd1f979b38f12e983dcaf76e
Reviewed-on: https://gerrit.libreoffice.org/41512
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'framework')
3 files changed, 9 insertions, 25 deletions
diff --git a/framework/source/uiconfiguration/CommandImageResolver.cxx b/framework/source/uiconfiguration/CommandImageResolver.cxx index 98aec12e3b4c..12d902d4bfd5 100644 --- a/framework/source/uiconfiguration/CommandImageResolver.cxx +++ b/framework/source/uiconfiguration/CommandImageResolver.cxx @@ -64,14 +64,10 @@ OUString lclConvertToCanonicalName(const OUString& rFileName) CommandImageResolver::CommandImageResolver() { - for (ImageList*& rp : m_pImageList) - rp = nullptr; } CommandImageResolver::~CommandImageResolver() { - for (ImageList* p : m_pImageList) - delete p; } bool CommandImageResolver::registerCommands(Sequence<OUString>& aCommandSequence) @@ -129,20 +125,17 @@ ImageList* CommandImageResolver::getImageList(ImageType nImageType) if (sIconTheme != m_sIconTheme) { m_sIconTheme = sIconTheme; - for (ImageList*& rp : m_pImageList) - { - delete rp; - rp = nullptr; - } + for (auto& rp : m_pImageList) + rp.reset(); } if (!m_pImageList[nImageType]) { OUString sIconPath = OUString::createFromAscii(ImageType_Prefixes[nImageType]); - m_pImageList[nImageType] = new ImageList(m_aImageNameVector, sIconPath); + m_pImageList[nImageType].reset( new ImageList(m_aImageNameVector, sIconPath) ); } - return m_pImageList[nImageType]; + return m_pImageList[nImageType].get(); } Image CommandImageResolver::getImageFromCommandURL(ImageType nImageType, const OUString& rCommandURL) diff --git a/framework/source/uiconfiguration/CommandImageResolver.hxx b/framework/source/uiconfiguration/CommandImageResolver.hxx index d7788e4e49bf..8d5a3c9ef309 100644 --- a/framework/source/uiconfiguration/CommandImageResolver.hxx +++ b/framework/source/uiconfiguration/CommandImageResolver.hxx @@ -18,6 +18,7 @@ #include "ImageList.hxx" +#include <memory> #include <unordered_map> #include <vector> @@ -33,7 +34,7 @@ private: std::vector<OUString> m_aImageCommandNameVector; std::vector<OUString> m_aImageNameVector; - o3tl::enumarray<ImageType, ImageList*> m_pImageList; + o3tl::enumarray<ImageType, std::unique_ptr<ImageList>> m_pImageList; OUString m_sIconTheme; ImageList* getImageList(ImageType nImageType); diff --git a/framework/source/uiconfiguration/moduleuiconfigurationmanager.cxx b/framework/source/uiconfiguration/moduleuiconfigurationmanager.cxx index aa94300e6154..96299c2bd83b 100644 --- a/framework/source/uiconfiguration/moduleuiconfigurationmanager.cxx +++ b/framework/source/uiconfiguration/moduleuiconfigurationmanager.cxx @@ -58,6 +58,7 @@ #include <rtl/ref.hxx> #include <rtl/ustrbuf.hxx> #include <comphelper/sequenceashashmap.hxx> +#include <memory> using namespace css; using namespace com::sun::star::uno; @@ -85,8 +86,6 @@ public: const css::uno::Reference< css::uno::XComponentContext >& xServiceManager, const css::uno::Sequence< css::uno::Any >& aArguments); - virtual ~ModuleUIConfigurationManager() override; - virtual OUString SAL_CALL getImplementationName() override { return OUString("com.sun.star.comp.framework.ModuleUIConfigurationManager"); @@ -201,7 +200,7 @@ private: void impl_reloadElementTypeData( UIElementType& rUserElementType, UIElementType const & rDefaultElementType, ConfigEventNotifyContainer& rRemoveNotifyContainer, ConfigEventNotifyContainer& rReplaceNotifyContainer ); UIElementTypesVector m_aUIElements[LAYER_COUNT]; - PresetHandler* m_pStorageHandler[css::ui::UIElementType::COUNT]; + std::unique_ptr<PresetHandler> m_pStorageHandler[css::ui::UIElementType::COUNT]; css::uno::Reference< css::embed::XStorage > m_xDefaultConfigStorage; css::uno::Reference< css::embed::XStorage > m_xUserConfigStorage; bool m_bReadOnly; @@ -854,9 +853,6 @@ ModuleUIConfigurationManager::ModuleUIConfigurationManager( , m_xContext( xContext ) , m_aListenerContainer( m_mutex ) { - for (PresetHandler* & i : m_pStorageHandler) - i = nullptr; - // Make sure we have a default initialized entry for every layer and user interface element type! // The following code depends on this! m_aUIElements[LAYER_DEFAULT].resize( css::ui::UIElementType::COUNT ); @@ -888,7 +884,7 @@ ModuleUIConfigurationManager::ModuleUIConfigurationManager( if ( !aResourceType.isEmpty() ) { - m_pStorageHandler[i] = new PresetHandler( m_xContext ); + m_pStorageHandler[i].reset( new PresetHandler( m_xContext ) ); m_pStorageHandler[i]->connectToResource( PresetHandler::E_MODULES, aResourceType, // this path won't be used later... see next lines! m_aModuleShortName, @@ -916,12 +912,6 @@ ModuleUIConfigurationManager::ModuleUIConfigurationManager( impl_Initialize(); } -ModuleUIConfigurationManager::~ModuleUIConfigurationManager() -{ - for (PresetHandler* i : m_pStorageHandler) - delete i; -} - // XComponent void SAL_CALL ModuleUIConfigurationManager::dispose() { |