summaryrefslogtreecommitdiff
path: root/sfx2
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2018-10-26 12:06:27 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2018-10-26 13:30:49 +0200
commit4054dff516367b332b7e3ce6fa91a452bf690571 (patch)
tree74ce35623e84933e4da9b134855ac1c74c4bce1d /sfx2
parentc0cc59adca23580864a2e5cdadf66212246cbfcc (diff)
use unique_ptr when Clone()'ing PoolItems
and fix a handful of small leaks in the process Change-Id: I876e12ff5305f9dda84532d4182fb91657d6fa0c Reviewed-on: https://gerrit.libreoffice.org/62389 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sfx2')
-rw-r--r--sfx2/source/appl/appopen.cxx7
-rw-r--r--sfx2/source/control/bindings.cxx8
2 files changed, 6 insertions, 9 deletions
diff --git a/sfx2/source/appl/appopen.cxx b/sfx2/source/appl/appopen.cxx
index 1c16308dbd4e..c54b3e58580b 100644
--- a/sfx2/source/appl/appopen.cxx
+++ b/sfx2/source/appl/appopen.cxx
@@ -942,11 +942,11 @@ void SfxApplication::OpenDocExec_Impl( SfxRequest& rReq )
pTargetFrame = &SfxViewFrame::Current()->GetFrame();
// check if caller has set a callback
- const SfxLinkItem* pLinkItem = rReq.GetArg<SfxLinkItem>(SID_DONELINK);
+ std::unique_ptr<SfxLinkItem> pLinkItem;
// remove from Itemset, because it confuses the parameter transformation
- if ( pLinkItem )
- pLinkItem = static_cast<SfxLinkItem*>( pLinkItem->Clone() );
+ if (auto pParamLinkItem = rReq.GetArg<SfxLinkItem>(SID_DONELINK))
+ pLinkItem.reset( static_cast<SfxLinkItem*>( pParamLinkItem->Clone() ) );
rReq.RemoveItem( SID_DONELINK );
@@ -1111,7 +1111,6 @@ void SfxApplication::OpenDocExec_Impl( SfxRequest& rReq )
{
pLinkItem->GetValue().Call(pRetValue);
}
- delete pLinkItem;
}
}
diff --git a/sfx2/source/control/bindings.cxx b/sfx2/source/control/bindings.cxx
index 2b2409be3369..29d49129f076 100644
--- a/sfx2/source/control/bindings.cxx
+++ b/sfx2/source/control/bindings.cxx
@@ -1018,20 +1018,18 @@ void SfxBindings::Execute_Impl( SfxRequest& aReq, const SfxSlot* pSlot, SfxShell
{
// we can toggle Bools
bool bOldValue = pOldBoolItem->GetValue();
- SfxBoolItem *pNewItem = static_cast<SfxBoolItem*>(pOldItem->Clone());
+ std::unique_ptr<SfxBoolItem> pNewItem(static_cast<SfxBoolItem*>(pOldItem->Clone()));
pNewItem->SetValue( !bOldValue );
aReq.AppendItem( *pNewItem );
- delete pNewItem;
}
else if ( dynamic_cast< const SfxEnumItemInterface *>( pOldItem ) != nullptr &&
static_cast<const SfxEnumItemInterface *>(pOldItem)->HasBoolValue())
{
// and Enums with Bool-Interface
- SfxEnumItemInterface *pNewItem =
- static_cast<SfxEnumItemInterface*>(pOldItem->Clone());
+ std::unique_ptr<SfxEnumItemInterface> pNewItem(
+ static_cast<SfxEnumItemInterface*>(pOldItem->Clone()));
pNewItem->SetBoolValue(!static_cast<const SfxEnumItemInterface *>(pOldItem)->GetBoolValue());
aReq.AppendItem( *pNewItem );
- delete pNewItem;
}
else {
OSL_FAIL( "Toggle only for Enums and Bools allowed" );