summaryrefslogtreecommitdiff
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
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>
-rw-r--r--cui/source/tabpages/chardlg.cxx3
-rw-r--r--include/sfx2/bindings.hxx5
-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
-rw-r--r--sd/source/ui/view/drviewsf.cxx20
-rw-r--r--sd/source/ui/view/outlnvsh.cxx5
-rw-r--r--sfx2/source/control/bindings.cxx18
-rw-r--r--sfx2/source/menu/mnumgr.cxx5
-rw-r--r--sfx2/source/sidebar/ControllerItem.cxx5
-rw-r--r--svx/source/dialog/rubydialog.cxx10
-rw-r--r--svx/source/fmcomp/fmgridcl.cxx7
-rw-r--r--sw/source/uibase/app/docst.cxx5
-rw-r--r--sw/source/uibase/docvw/romenu.cxx15
14 files changed, 49 insertions, 70 deletions
diff --git a/cui/source/tabpages/chardlg.cxx b/cui/source/tabpages/chardlg.cxx
index 9e47e2469dd1..ed1a26d09546 100644
--- a/cui/source/tabpages/chardlg.cxx
+++ b/cui/source/tabpages/chardlg.cxx
@@ -1468,7 +1468,7 @@ void SvxCharEffectsPage::Initialize()
m_pFontColorLB->SetUpdateMode( false );
{
- SfxPoolItem* pDummy = nullptr;
+ std::unique_ptr<SfxPoolItem> pDummy;
SfxViewFrame* pFrame = SfxViewFrame::GetFirst( pDocSh );
if ( !pFrame ||
SfxItemState::DEFAULT > pFrame->GetBindings().QueryState( SID_ATTR_AUTO_COLOR_INVALID, pDummy ) )
@@ -1477,7 +1477,6 @@ void SvxCharEffectsPage::Initialize()
m_pOverlineColorLB->InsertAutomaticEntryColor( Color( COL_AUTO ) );
m_pFontColorLB->InsertAutomaticEntryColor( Color( COL_AUTO ) );
}
- delete pDummy;
}
for ( long i = 0; i < pColorTable->Count(); i++ )
{
diff --git a/include/sfx2/bindings.hxx b/include/sfx2/bindings.hxx
index bbe5cc46cda9..413ce7ebd9a5 100644
--- a/include/sfx2/bindings.hxx
+++ b/include/sfx2/bindings.hxx
@@ -20,6 +20,9 @@
#define INCLUDED_SFX2_BINDINGS_HXX
#include <sal/config.h>
+
+#include <memory>
+
#include <sfx2/dllapi.h>
#include <sal/types.h>
#include <rtl/strbuf.hxx>
@@ -163,7 +166,7 @@ public:
/**
* @param rpState the caller has to delete the pointer
*/
- SfxItemState QueryState( sal_uInt16 nSID, SfxPoolItem* &rpState );
+ SfxItemState QueryState( sal_uInt16 nSID, std::unique_ptr<SfxPoolItem> &rpState );
const SfxPoolItem* ExecuteSynchron( sal_uInt16 nSlot,
const SfxPoolItem **pArgs = nullptr,
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;
}
diff --git a/sd/source/ui/view/drviewsf.cxx b/sd/source/ui/view/drviewsf.cxx
index d3e8276e70ef..15bb40e9aa6c 100644
--- a/sd/source/ui/view/drviewsf.cxx
+++ b/sd/source/ui/view/drviewsf.cxx
@@ -488,9 +488,9 @@ void DrawViewShell::GetAttrState( SfxItemSet& rSet )
case SID_STYLE_WATERCAN:
{
- SfxPoolItem* pItem = nullptr;
+ std::unique_ptr<SfxPoolItem> pItem;
GetViewFrame()->GetBindings().QueryState(SID_STYLE_FAMILY, pItem);
- SfxUInt16Item* pFamilyItem = dynamic_cast<SfxUInt16Item*>(pItem);
+ SfxUInt16Item* pFamilyItem = dynamic_cast<SfxUInt16Item*>(pItem.get());
if (pFamilyItem && SfxTemplate::NIdToSfxFamilyId(pFamilyItem->GetValue()) == SD_STYLE_FAMILY_PSEUDO)
rSet.Put(SfxBoolItem(nWhich,false));
else
@@ -498,31 +498,28 @@ void DrawViewShell::GetAttrState( SfxItemSet& rSet )
SfxBoolItem aItem(nWhich, SD_MOD()->GetWaterCan());
aAllSet.Put( aItem, aItem.Which());
}
- delete pItem;
}
break;
case SID_STYLE_NEW:
{
- SfxPoolItem* pItem = nullptr;
+ std::unique_ptr<SfxPoolItem> pItem;
GetViewFrame()->GetBindings().QueryState(SID_STYLE_FAMILY, pItem);
- SfxUInt16Item* pFamilyItem = dynamic_cast<SfxUInt16Item*>(pItem);
+ SfxUInt16Item* pFamilyItem = dynamic_cast<SfxUInt16Item*>(pItem.get());
if (pFamilyItem && SfxTemplate::NIdToSfxFamilyId(pFamilyItem->GetValue()) == SD_STYLE_FAMILY_PSEUDO)
{
rSet.DisableItem(nWhich);
}
- delete pItem;
}
break;
case SID_STYLE_DRAGHIERARCHIE:
{
- SfxPoolItem* pItem = nullptr;
+ std::unique_ptr<SfxPoolItem> pItem;
GetViewFrame()->GetBindings().QueryState(SID_STYLE_FAMILY, pItem);
- SfxUInt16Item* pFamilyItem = dynamic_cast<SfxUInt16Item*>(pItem);
+ SfxUInt16Item* pFamilyItem = dynamic_cast<SfxUInt16Item*>(pItem.get());
if (pFamilyItem && SfxTemplate::NIdToSfxFamilyId(pFamilyItem->GetValue()) == SD_STYLE_FAMILY_PSEUDO)
rSet.DisableItem(nWhich);
- delete pItem;
}
break;
@@ -531,9 +528,9 @@ void DrawViewShell::GetAttrState( SfxItemSet& rSet )
// It is not possible to create PseudoStyleSheets 'by Example';
// normal style sheets need a selected object for that
- SfxPoolItem* pItem = nullptr;
+ std::unique_ptr<SfxPoolItem> pItem;
GetViewFrame()->GetBindings().QueryState(SID_STYLE_FAMILY, pItem);
- SfxUInt16Item* pFamilyItem = dynamic_cast<SfxUInt16Item*>(pItem);
+ SfxUInt16Item* pFamilyItem = dynamic_cast<SfxUInt16Item*>(pItem.get());
if (pFamilyItem)
{
if (SfxTemplate::NIdToSfxFamilyId(pFamilyItem->GetValue()) == SD_STYLE_FAMILY_PSEUDO)
@@ -557,7 +554,6 @@ void DrawViewShell::GetAttrState( SfxItemSet& rSet )
rSet.DisableItem(nWhich);
}
}
- delete pItem;
}
break;
diff --git a/sd/source/ui/view/outlnvsh.cxx b/sd/source/ui/view/outlnvsh.cxx
index 8acacd4459ca..c81906ba648e 100644
--- a/sd/source/ui/view/outlnvsh.cxx
+++ b/sd/source/ui/view/outlnvsh.cxx
@@ -1481,9 +1481,9 @@ void OutlineViewShell::GetAttrState( SfxItemSet& rSet )
case SID_STYLE_EDIT:
{
- SfxPoolItem* pItem = nullptr;
+ std::unique_ptr<SfxPoolItem> pItem;
GetViewFrame()->GetBindings().QueryState(SID_STYLE_FAMILY, pItem);
- SfxUInt16Item* pFamilyItem = dynamic_cast<SfxUInt16Item*>(pItem);
+ SfxUInt16Item* pFamilyItem = dynamic_cast<SfxUInt16Item*>(pItem.get());
if (pFamilyItem && SfxTemplate::NIdToSfxFamilyId(pFamilyItem->GetValue()) == SD_STYLE_FAMILY_PSEUDO)
{
SfxItemSet aSet(*rSet.GetPool(), SID_STATUS_LAYOUT, SID_STATUS_LAYOUT);
@@ -1495,7 +1495,6 @@ void OutlineViewShell::GetAttrState( SfxItemSet& rSet )
rSet.DisableItem(nWhich);
}
}
- delete pItem;
}
break;
diff --git a/sfx2/source/control/bindings.cxx b/sfx2/source/control/bindings.cxx
index 5d1369315421..41b5194953fd 100644
--- a/sfx2/source/control/bindings.cxx
+++ b/sfx2/source/control/bindings.cxx
@@ -1879,7 +1879,7 @@ void SfxBindings::StartUpdate_Impl( bool bComplete )
-SfxItemState SfxBindings::QueryState( sal_uInt16 nSlot, SfxPoolItem* &rpState )
+SfxItemState SfxBindings::QueryState( sal_uInt16 nSlot, std::unique_ptr<SfxPoolItem> &rpState )
{
css::uno::Reference< css::frame::XDispatch > xDisp;
SfxStateCache *pCache = GetStateCache( nSlot );
@@ -1923,7 +1923,6 @@ SfxItemState SfxBindings::QueryState( sal_uInt16 nSlot, SfxPoolItem* &rpState )
}
SfxItemState eState = SfxItemState::SET;
- SfxPoolItem *pItem=nullptr;
BindDispatch_Impl *pBind = new BindDispatch_Impl( xDisp, aURL, pCache, pSlot );
pBind->acquire();
xDisp->addStatusListener( pBind, aURL );
@@ -1940,33 +1939,32 @@ SfxItemState SfxBindings::QueryState( sal_uInt16 nSlot, SfxPoolItem* &rpState )
{
bool bTemp = false;
aAny >>= bTemp ;
- pItem = new SfxBoolItem( nSlot, bTemp );
+ rpState.reset(new SfxBoolItem( nSlot, bTemp ));
}
else if ( pType == ::cppu::UnoType< ::cppu::UnoUnsignedShortType >::get() )
{
sal_uInt16 nTemp = 0;
aAny >>= nTemp ;
- pItem = new SfxUInt16Item( nSlot, nTemp );
+ rpState.reset(new SfxUInt16Item( nSlot, nTemp ));
}
else if ( pType == cppu::UnoType<sal_uInt32>::get() )
{
sal_uInt32 nTemp = 0;
aAny >>= nTemp ;
- pItem = new SfxUInt32Item( nSlot, nTemp );
+ rpState.reset(new SfxUInt32Item( nSlot, nTemp ));
}
else if ( pType == cppu::UnoType<OUString>::get() )
{
OUString sTemp ;
aAny >>= sTemp ;
- pItem = new SfxStringItem( nSlot, sTemp );
+ rpState.reset(new SfxStringItem( nSlot, sTemp ));
}
else
- pItem = new SfxVoidItem( nSlot );
+ rpState.reset(new SfxVoidItem( nSlot ));
}
xDisp->removeStatusListener( pBind, aURL );
pBind->Release();
- rpState = pItem;
if ( bDeleteCache )
DELETEZ( pCache );
return eState;
@@ -1983,11 +1981,11 @@ SfxItemState SfxBindings::QueryState( sal_uInt16 nSlot, SfxPoolItem* &rpState )
{
DBG_ASSERT( pItem, "SfxItemState::SET but no item!" );
if ( pItem )
- rpState = pItem->Clone();
+ rpState.reset(pItem->Clone());
}
else if ( eState == SfxItemState::DEFAULT && pItem )
{
- rpState = pItem->Clone();
+ rpState.reset(pItem->Clone());
}
return eState;
diff --git a/sfx2/source/menu/mnumgr.cxx b/sfx2/source/menu/mnumgr.cxx
index 908c3667938a..00438ff78aff 100644
--- a/sfx2/source/menu/mnumgr.cxx
+++ b/sfx2/source/menu/mnumgr.cxx
@@ -134,17 +134,16 @@ PopupMenu* InsertThesaurusSubmenu_Impl( SfxBindings* pBindings, Menu* pSVMenu )
// build thesaurus sub menu if look-up string is available
PopupMenu* pThesSubMenu = nullptr;
- SfxPoolItem *pItem = nullptr;
+ std::unique_ptr<SfxPoolItem> pItem;
pBindings->QueryState( SID_THES, pItem );
OUString aThesLookUpStr;
- SfxStringItem *pStrItem = dynamic_cast< SfxStringItem * >(pItem);
+ SfxStringItem *pStrItem = dynamic_cast< SfxStringItem * >(pItem.get());
sal_Int32 nDelimPos = -1;
if (pStrItem)
{
aThesLookUpStr = pStrItem->GetValue();
nDelimPos = aThesLookUpStr.lastIndexOf( '#' );
}
- delete pItem;
if ( !aThesLookUpStr.isEmpty() && nDelimPos != -1 )
{
// get synonym list for sub menu
diff --git a/sfx2/source/sidebar/ControllerItem.cxx b/sfx2/source/sidebar/ControllerItem.cxx
index ed4fa3b1f365..d6243c80ce22 100644
--- a/sfx2/source/sidebar/ControllerItem.cxx
+++ b/sfx2/source/sidebar/ControllerItem.cxx
@@ -164,10 +164,9 @@ bool ControllerItem::IsEnabled (SfxItemState eState) const
void ControllerItem::RequestUpdate()
{
- SfxPoolItem* pState = nullptr;
+ std::unique_ptr<SfxPoolItem> pState;
const SfxItemState eState (GetBindings().QueryState(GetId(), pState));
- mrItemUpdateReceiver.NotifyItemUpdate(GetId(), eState, pState, IsEnabled(eState));
- delete pState;
+ mrItemUpdateReceiver.NotifyItemUpdate(GetId(), eState, pState.get(), IsEnabled(eState));
}
void ControllerItem::NotifyFrameContextChange()
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;
}
}
}
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() )
{