diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-09-11 17:13:03 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-09-12 09:08:13 +0200 |
commit | 7281f4a73ec3679798a6271ab5a0ad839f278e37 (patch) | |
tree | 3cca53740da25547641c8c8d31dd673aee9d7b35 /svtools | |
parent | 8ff99af537b2daff07717990be10780ad6824f25 (diff) |
use std::unique_ptr in TItemInfo
and inline the TItems typedef
Change-Id: I0c50d12d53ce4b52c330cad8790a65065ebdd82e
Reviewed-on: https://gerrit.libreoffice.org/42182
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Tested-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'svtools')
-rw-r--r-- | svtools/source/config/itemholder2.cxx | 33 | ||||
-rw-r--r-- | svtools/source/config/itemholder2.hxx | 2 |
2 files changed, 12 insertions, 23 deletions
diff --git a/svtools/source/config/itemholder2.cxx b/svtools/source/config/itemholder2.cxx index 5989157f5e8b..2512715caab8 100644 --- a/svtools/source/config/itemholder2.cxx +++ b/svtools/source/config/itemholder2.cxx @@ -91,12 +91,8 @@ void ItemHolder2::impl_addItem(EItem eItem) { ::osl::ResettableMutexGuard aLock(m_aLock); - TItems::const_iterator pIt; - for ( pIt = m_lItems.begin(); - pIt != m_lItems.end() ; - ++pIt ) + for ( auto const & rInfo : m_lItems ) { - const TItemInfo& rInfo = *pIt; if (rInfo.eItem == eItem) return; } @@ -105,26 +101,19 @@ void ItemHolder2::impl_addItem(EItem eItem) aNewItem.eItem = eItem; impl_newItem(aNewItem); if (aNewItem.pItem) - m_lItems.push_back(aNewItem); + m_lItems.emplace_back(std::move(aNewItem)); } void ItemHolder2::impl_releaseAllItems() { - TItems items; + std::vector<TItemInfo> items; { ::osl::ResettableMutexGuard aLock(m_aLock); items.swap(m_lItems); } - TItems::iterator pIt; - for ( pIt = items.begin(); - pIt != items.end() ; - ++pIt ) - { - delete pIt->pItem; - } - m_lItems.clear(); + // items will be freed when the block exits } @@ -133,31 +122,31 @@ void ItemHolder2::impl_newItem(TItemInfo& rItem) switch(rItem.eItem) { case EItem::AccessibilityOptions : - rItem.pItem = new SvtAccessibilityOptions(); + rItem.pItem.reset( new SvtAccessibilityOptions() ); break; case EItem::ColorConfig : - rItem.pItem = new ::svtools::ColorConfig(); + rItem.pItem.reset( new ::svtools::ColorConfig() ); break; case EItem::HelpOptions : - rItem.pItem = new SvtHelpOptions(); + rItem.pItem.reset( new SvtHelpOptions() ); break; case EItem::MenuOptions : - rItem.pItem = new SvtMenuOptions(); + rItem.pItem.reset( new SvtMenuOptions() ); break; case EItem::PrintOptions : - rItem.pItem = new SvtPrinterOptions(); + rItem.pItem.reset( new SvtPrinterOptions() ); break; case EItem::PrintFileOptions : - rItem.pItem = new SvtPrintFileOptions(); + rItem.pItem.reset( new SvtPrintFileOptions() ); break; case EItem::MiscOptions : - rItem.pItem = new SvtMiscOptions(); + rItem.pItem.reset( new SvtMiscOptions() ); break; default: diff --git a/svtools/source/config/itemholder2.hxx b/svtools/source/config/itemholder2.hxx index bf344e4f3b92..110fbe254fd4 100644 --- a/svtools/source/config/itemholder2.hxx +++ b/svtools/source/config/itemholder2.hxx @@ -34,7 +34,7 @@ class ItemHolder2 : private ItemHolderMutexBase // member private: - TItems m_lItems; + std::vector<TItemInfo> m_lItems; // c++ interface |