diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-09-04 13:08:59 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-09-05 09:31:50 +0200 |
commit | d2b3ea4d377bf05830f6eb11d53fd55ea6b435fc (patch) | |
tree | a9ca855eac45810e67d6e629538de13b2a9e589d /sfx2/source/control/bindings.cxx | |
parent | 7a11e702569ab89eb7722c883ecc3cbbe1a19a65 (diff) |
loplugin:useuniqueptr in sfx2
Change-Id: I7b406cd07cae579de608faa3ec47dd1190dea411
Reviewed-on: https://gerrit.libreoffice.org/60003
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sfx2/source/control/bindings.cxx')
-rw-r--r-- | sfx2/source/control/bindings.cxx | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/sfx2/source/control/bindings.cxx b/sfx2/source/control/bindings.cxx index b65ccbf08892..031a52694dc0 100644 --- a/sfx2/source/control/bindings.cxx +++ b/sfx2/source/control/bindings.cxx @@ -1040,27 +1040,26 @@ void SfxBindings::Execute_Impl( SfxRequest& aReq, const SfxSlot* pSlot, SfxShell else if ( SfxItemState::DONTCARE == eState ) { // Create one Status-Item for each Factory - SfxPoolItem *pNewItem = pSlot->GetType()->CreateItem(); + std::unique_ptr<SfxPoolItem> pNewItem = pSlot->GetType()->CreateItem(); DBG_ASSERT( pNewItem, "Toggle to slot without ItemFactory" ); pNewItem->SetWhich( nWhich ); - if ( dynamic_cast< const SfxBoolItem *>( pNewItem ) != nullptr ) + if ( auto pNewBoolItem = dynamic_cast<SfxBoolItem *>( pNewItem.get() ) ) { // we can toggle Bools - static_cast<SfxBoolItem*>(pNewItem)->SetValue( true ); + pNewBoolItem->SetValue( true ); aReq.AppendItem( *pNewItem ); } - else if ( dynamic_cast< const SfxEnumItemInterface *>( pNewItem ) != nullptr && - static_cast<SfxEnumItemInterface *>(pNewItem)->HasBoolValue()) + else if ( dynamic_cast< const SfxEnumItemInterface *>( pNewItem.get() ) != nullptr && + static_cast<SfxEnumItemInterface *>(pNewItem.get())->HasBoolValue()) { // and Enums with Bool-Interface - static_cast<SfxEnumItemInterface*>(pNewItem)->SetBoolValue(true); + static_cast<SfxEnumItemInterface*>(pNewItem.get())->SetBoolValue(true); aReq.AppendItem( *pNewItem ); } else { OSL_FAIL( "Toggle only for Enums and Bools allowed" ); } - delete pNewItem; } else { OSL_FAIL( "suspicious Toggle-Slot" ); |