summaryrefslogtreecommitdiff
path: root/svx
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 /svx
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 'svx')
-rw-r--r--svx/source/dialog/rubydialog.cxx10
-rw-r--r--svx/source/fmcomp/fmgridcl.cxx7
2 files changed, 7 insertions, 10 deletions
diff --git a/svx/source/dialog/rubydialog.cxx b/svx/source/dialog/rubydialog.cxx
index 6e308197ffa7..1dffa9b54b24 100644
--- a/svx/source/dialog/rubydialog.cxx
+++ b/svx/source/dialog/rubydialog.cxx
@@ -326,10 +326,9 @@ bool SvxRubyDialog::Close()
void SvxRubyDialog::Activate()
{
SfxModelessDialog::Activate();
- SfxPoolItem* pState = nullptr;
+ std::unique_ptr<SfxPoolItem> pState;
SfxItemState eState = pBindings->QueryState( SID_STYLE_DESIGNER, pState );
- bool bEnable = (eState < SfxItemState::DEFAULT) || !pState || !static_cast<SfxBoolItem*>(pState)->GetValue();
- delete pState;
+ bool bEnable = (eState < SfxItemState::DEFAULT) || !pState || !static_cast<SfxBoolItem*>(pState.get())->GetValue();
m_pStylistPB->Enable(bEnable);
//get selection from current view frame
SfxViewFrame* pCurFrm = SfxViewFrame::Current();
@@ -598,14 +597,13 @@ IMPL_LINK_NOARG_TYPED(SvxRubyDialog, CloseHdl_Impl, Button*, void)
IMPL_LINK_NOARG_TYPED(SvxRubyDialog, StylistHdl_Impl, Button*, void)
{
- SfxPoolItem* pState = nullptr;
+ std::unique_ptr<SfxPoolItem> pState;
SfxItemState eState = pBindings->QueryState(SID_STYLE_DESIGNER, pState);
- if (eState <= SfxItemState::SET || !pState || !static_cast<SfxBoolItem*>(pState)->GetValue())
+ if (eState <= SfxItemState::SET || !pState || !static_cast<SfxBoolItem*>(pState.get())->GetValue())
{
pBindings->GetDispatcher()->Execute(SID_STYLE_DESIGNER,
SfxCallMode::ASYNCHRON | SfxCallMode::RECORD);
}
- delete pState;
}
IMPL_LINK_TYPED(SvxRubyDialog, AdjustHdl_Impl, ListBox&, rBox, void)
diff --git a/svx/source/fmcomp/fmgridcl.cxx b/svx/source/fmcomp/fmgridcl.cxx
index 2de79055f8af..2e5c50ce9006 100644
--- a/svx/source/fmcomp/fmgridcl.cxx
+++ b/svx/source/fmcomp/fmgridcl.cxx
@@ -761,15 +761,14 @@ void FmGridHeader::PreExecuteColumnContextMenu(sal_uInt16 nColId, PopupMenu& rMe
// ask the bindings of the current view frame (which should be the one we're residing in) for the state
if (pCurrentFrame)
{
- SfxPoolItem* pItem = nullptr;
+ std::unique_ptr<SfxPoolItem> pItem;
eState = pCurrentFrame->GetBindings().QueryState(SID_FM_CTL_PROPERTIES, pItem);
- if (eState >= SfxItemState::DEFAULT && pItem )
+ if (eState >= SfxItemState::DEFAULT && pItem.get() != nullptr )
{
- bool bChecked = dynamic_cast<const SfxBoolItem*>( pItem) != nullptr && static_cast<SfxBoolItem*>(pItem)->GetValue();
+ bool bChecked = dynamic_cast<const SfxBoolItem*>( pItem.get()) != nullptr && static_cast<SfxBoolItem*>(pItem.get())->GetValue();
rMenu.CheckItem(SID_FM_SHOW_PROPERTY_BROWSER,bChecked);
}
- delete pItem;
}
}
}