summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2015-12-08 18:57:32 +0100
committerStephan Bergmann <sbergman@redhat.com>2015-12-09 07:16:34 +0000
commit4754afddc3030347ef49b401a9b798cea8fe523c (patch)
treea7505da2dae9b8eae70ed463309521c11780d4c4 /sc
parent6fd3f3caad1a559165dc9332249cbd0d84930775 (diff)
Use unique_ptr out-arg to in SfxBindings::QueryState to avoid mem leaks
Change-Id: I35df02de675068478a36ef05266ffc2d3054b07f Reviewed-on: https://gerrit.libreoffice.org/20477 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'sc')
-rw-r--r--sc/source/ui/view/cellsh3.cxx6
-rw-r--r--sc/source/ui/view/formatsh.cxx10
-rw-r--r--sc/source/ui/view/viewutil.cxx5
3 files changed, 8 insertions, 13 deletions
diff --git a/sc/source/ui/view/cellsh3.cxx b/sc/source/ui/view/cellsh3.cxx
index d2fd259467b8..ff6822f6b576 100644
--- a/sc/source/ui/view/cellsh3.cxx
+++ b/sc/source/ui/view/cellsh3.cxx
@@ -729,11 +729,9 @@ void ScCellShell::Execute( SfxRequest& rReq )
case FID_MERGE_TOGGLE:
{
bCenter = true;
- SfxPoolItem* pItem = nullptr;
+ std::unique_ptr<SfxPoolItem> pItem;
if( rBindings.QueryState( nSlot, pItem ) >= SfxItemState::DEFAULT )
- bMerge = !static_cast< SfxBoolItem* >( pItem )->GetValue();
-
- delete pItem;
+ bMerge = !static_cast< SfxBoolItem* >( pItem.get() )->GetValue();
}
break;
}
diff --git a/sc/source/ui/view/formatsh.cxx b/sc/source/ui/view/formatsh.cxx
index 7f19086254a8..abd34e4ac04f 100644
--- a/sc/source/ui/view/formatsh.cxx
+++ b/sc/source/ui/view/formatsh.cxx
@@ -212,12 +212,11 @@ void ScFormatShell::GetStyleState( SfxItemSet& rSet )
case SID_STYLE_UPDATE_BY_EXAMPLE:
{
- SfxPoolItem* pItem = nullptr;
+ std::unique_ptr<SfxPoolItem> pItem;
pTabViewShell->GetViewFrame()->GetBindings().QueryState(SID_STYLE_FAMILY, pItem);
- SfxUInt16Item* pFamilyItem = dynamic_cast<SfxUInt16Item*>(pItem);
+ SfxUInt16Item* pFamilyItem = dynamic_cast<SfxUInt16Item*>(pItem.get());
bool bPage = pFamilyItem && SFX_STYLE_FAMILY_PAGE == SfxTemplate::NIdToSfxFamilyId(pFamilyItem->GetValue());
- delete pItem;
if ( bProtected || bPage )
rSet.DisableItem( nSlotId );
@@ -229,11 +228,10 @@ void ScFormatShell::GetStyleState( SfxItemSet& rSet )
case SID_STYLE_HIDE:
case SID_STYLE_SHOW:
{
- SfxPoolItem* pItem = nullptr;
+ std::unique_ptr<SfxPoolItem> pItem;
pTabViewShell->GetViewFrame()->GetBindings().QueryState(SID_STYLE_FAMILY, pItem);
- SfxUInt16Item* pFamilyItem = dynamic_cast<SfxUInt16Item*>(pItem);
+ SfxUInt16Item* pFamilyItem = dynamic_cast<SfxUInt16Item*>(pItem.get());
bool bPage = pFamilyItem && SFX_STYLE_FAMILY_PAGE == SfxTemplate::NIdToSfxFamilyId(pFamilyItem->GetValue());
- delete pItem;
if ( bProtected && !bPage )
rSet.DisableItem( nSlotId );
diff --git a/sc/source/ui/view/viewutil.cxx b/sc/source/ui/view/viewutil.cxx
index 4f71d63bfc8e..41df6e598b5e 100644
--- a/sc/source/ui/view/viewutil.cxx
+++ b/sc/source/ui/view/viewutil.cxx
@@ -368,12 +368,11 @@ bool ScViewUtil::ExecuteCharMap( const SvxFontItem& rOldFont,
bool ScViewUtil::IsFullScreen( SfxViewShell& rViewShell )
{
SfxBindings& rBindings = rViewShell.GetViewFrame()->GetBindings();
- SfxPoolItem* pItem = nullptr;
+ std::unique_ptr<SfxPoolItem> pItem;
bool bIsFullScreen = false;
if (rBindings.QueryState( SID_WIN_FULLSCREEN, pItem ) >= SfxItemState::DEFAULT)
- bIsFullScreen = static_cast< SfxBoolItem* >( pItem )->GetValue();
- delete pItem;
+ bIsFullScreen = static_cast< SfxBoolItem* >( pItem.get() )->GetValue();
return bIsFullScreen;
}