summaryrefslogtreecommitdiff
path: root/sw/source/uibase
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 /sw/source/uibase
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 'sw/source/uibase')
-rw-r--r--sw/source/uibase/app/docst.cxx5
-rw-r--r--sw/source/uibase/docvw/romenu.cxx15
2 files changed, 7 insertions, 13 deletions
diff --git a/sw/source/uibase/app/docst.cxx b/sw/source/uibase/app/docst.cxx
index e29f91098dce..cdd704ef0b27 100644
--- a/sw/source/uibase/app/docst.cxx
+++ b/sw/source/uibase/app/docst.cxx
@@ -108,14 +108,13 @@ void SwDocShell::StateStyleSheet(SfxItemSet& rSet, SwWrtShell* pSh)
else
{
SfxViewFrame* pFrame = pShell->GetView().GetViewFrame();
- SfxPoolItem* pItem = nullptr;
+ std::unique_ptr<SfxPoolItem> pItem;
pFrame->GetBindings().QueryState(SID_STYLE_FAMILY, pItem);
- SfxUInt16Item* pFamilyItem = dynamic_cast<SfxUInt16Item*>(pItem);
+ SfxUInt16Item* pFamilyItem = dynamic_cast<SfxUInt16Item*>(pItem.get());
if (pFamilyItem)
{
nActualFamily = static_cast<sal_uInt16>(SfxTemplate::NIdToSfxFamilyId(pFamilyItem->GetValue()));
}
- delete pItem;
}
while (nWhich)
diff --git a/sw/source/uibase/docvw/romenu.cxx b/sw/source/uibase/docvw/romenu.cxx
index f7abc6a90d2b..c7de73d2651b 100644
--- a/sw/source/uibase/docvw/romenu.cxx
+++ b/sw/source/uibase/docvw/romenu.cxx
@@ -59,16 +59,16 @@ SwReadOnlyPopup::~SwReadOnlyPopup()
void SwReadOnlyPopup::Check( sal_uInt16 nMID, sal_uInt16 nSID, SfxDispatcher &rDis )
{
- SfxPoolItem *_pItem = nullptr;
+ std::unique_ptr<SfxPoolItem> _pItem;
SfxItemState eState = rDis.GetBindings()->QueryState( nSID, _pItem );
if (eState >= SfxItemState::DEFAULT)
{
EnableItem( nMID );
if (_pItem)
{
- CheckItem ( nMID, dynamic_cast< const SfxVoidItem *>( _pItem ) == nullptr &&
- dynamic_cast< const SfxBoolItem *>( _pItem ) != nullptr &&
- static_cast<SfxBoolItem*>(_pItem)->GetValue());
+ CheckItem ( nMID, dynamic_cast< const SfxVoidItem *>( _pItem.get() ) == nullptr &&
+ dynamic_cast< const SfxBoolItem *>( _pItem.get() ) != nullptr &&
+ static_cast<SfxBoolItem*>(_pItem.get())->GetValue());
//remove full screen entry when not in full screen mode
if( SID_WIN_FULLSCREEN == nSID && !IsItemChecked(SID_WIN_FULLSCREEN) )
EnableItem(nMID, false);
@@ -76,8 +76,6 @@ void SwReadOnlyPopup::Check( sal_uInt16 nMID, sal_uInt16 nSID, SfxDispatcher &rD
}
else
EnableItem( nMID, false );
-
- delete _pItem;
}
SwReadOnlyPopup::SwReadOnlyPopup( const Point &rDPos, SwView &rV ) :
@@ -198,14 +196,12 @@ SwReadOnlyPopup::SwReadOnlyPopup( const Point &rDPos, SwView &rV ) :
Check( MN_READONLY_OPENURL, SID_OPENDOC, rDis );
Check( MN_READONLY_OPENURLNEW, SID_OPENDOC, rDis );
- SfxPoolItem* pState = nullptr;
+ std::unique_ptr<SfxPoolItem> pState;
SfxItemState eState = pVFrame->GetBindings().QueryState( SID_COPY, pState );
Check( MN_READONLY_COPY, SID_COPY, rDis );
if(eState < SfxItemState::DEFAULT)
EnableItem( MN_READONLY_COPY, false );
- delete pState;
- pState = nullptr;
eState = pVFrame->GetBindings().QueryState( SID_EDITDOC, pState );
if (
@@ -215,7 +211,6 @@ SwReadOnlyPopup::SwReadOnlyPopup( const Point &rDPos, SwView &rV ) :
{
EnableItem( MN_READONLY_EDITDOC, false );
}
- delete pState;
if ( sURL.isEmpty() )
{