fix leak in SfxApplication::OpenDocExec_Impl
when calling Link on SfxLinkItem, none of the callee sites free the memory associated with the Clone()'ed SfxPoolItem, so just skip the cloning, and make the Link take a const pointer to make this more obvious. Change-Id: Icd187e9d8d3ace9bf2e6ff183489999b105708e4 Reviewed-on: https://gerrit.libreoffice.org/55671 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
This commit is contained in:
parent
6b03d6f3b2
commit
59935c3149
7 changed files with 10 additions and 11 deletions
|
@ -118,7 +118,7 @@ private:
|
|||
SvxNumberInfoItem* pNumItem;
|
||||
SvxNumberFormatShell* pNumFmtShell;
|
||||
sal_uLong nInitFormat;
|
||||
Link<SfxPoolItem*,void> fnOkHdl;
|
||||
Link<SfxPoolItem const *,void> fnOkHdl;
|
||||
|
||||
bool bNumItemFlag; ///< for handling with DocShell
|
||||
bool bOneAreaFlag;
|
||||
|
|
|
@ -99,16 +99,16 @@ enum class SfxToolsModule
|
|||
|
||||
class SFX2_DLLPUBLIC SfxLinkItem : public SfxPoolItem
|
||||
{
|
||||
Link<SfxPoolItem*, void> aLink;
|
||||
Link<SfxPoolItem const *, void> aLink;
|
||||
public:
|
||||
SfxLinkItem( sal_uInt16 nWhichId, const Link<SfxPoolItem*, void>& rValue ) : SfxPoolItem( nWhichId )
|
||||
SfxLinkItem( sal_uInt16 nWhichId, const Link<SfxPoolItem const *, void>& rValue ) : SfxPoolItem( nWhichId )
|
||||
{ aLink = rValue; }
|
||||
|
||||
virtual SfxPoolItem* Clone( SfxItemPool* = nullptr ) const override
|
||||
{ return new SfxLinkItem( *this ); }
|
||||
virtual bool operator==( const SfxPoolItem& rL) const override
|
||||
{ return static_cast<const SfxLinkItem&>(rL).aLink == aLink; }
|
||||
const Link<SfxPoolItem*, void>&
|
||||
const Link<SfxPoolItem const *, void>&
|
||||
GetValue() const { return aLink; }
|
||||
};
|
||||
|
||||
|
|
|
@ -86,7 +86,7 @@ void ScAttrDlg::PageCreated( sal_uInt16 nPageId, SfxTabPage& rTabPage )
|
|||
}
|
||||
}
|
||||
|
||||
IMPL_LINK_NOARG(ScAttrDlg, OkHandler, SfxPoolItem*, void)
|
||||
IMPL_LINK_NOARG(ScAttrDlg, OkHandler, SfxPoolItem const *, void)
|
||||
{
|
||||
GetOKButton().GetClickHdl().Call( nullptr );
|
||||
}
|
||||
|
|
|
@ -37,7 +37,7 @@ protected:
|
|||
virtual void PageCreated( sal_uInt16 nPageId, SfxTabPage& rTabPage ) override;
|
||||
|
||||
private:
|
||||
DECL_LINK( OkHandler, SfxPoolItem*, void ); // for closing by double clicking in TabPages
|
||||
DECL_LINK( OkHandler, SfxPoolItem const *, void ); // for closing by double clicking in TabPages
|
||||
sal_uInt16 m_nNumberPageId;
|
||||
sal_uInt16 m_nFontPageId;
|
||||
};
|
||||
|
|
|
@ -1122,8 +1122,7 @@ void SfxApplication::OpenDocExec_Impl( SfxRequest& rReq )
|
|||
const SfxPoolItem* pRetValue = rReq.GetReturnValue();
|
||||
if (pRetValue)
|
||||
{
|
||||
SfxPoolItem* pClone = pRetValue->Clone();
|
||||
pLinkItem->GetValue().Call(pClone);
|
||||
pLinkItem->GetValue().Call(pRetValue);
|
||||
}
|
||||
delete pLinkItem;
|
||||
}
|
||||
|
|
|
@ -111,7 +111,7 @@ class SwNavigationPI : public PanelLayout,
|
|||
DECL_LINK( ToolBoxDropdownClickHdl, ToolBox*, void );
|
||||
DECL_LINK( EditAction, NumEditAction&, void );
|
||||
DECL_LINK( EditGetFocus, Control&, void );
|
||||
DECL_LINK( DoneLink, SfxPoolItem *, void );
|
||||
DECL_LINK( DoneLink, SfxPoolItem const *, void );
|
||||
DECL_LINK( MenuSelectHdl, Menu *, bool );
|
||||
DECL_LINK( ChangePageHdl, Timer*, void );
|
||||
DECL_LINK( PageEditModifyHdl, SpinField&, void );
|
||||
|
|
|
@ -1014,9 +1014,9 @@ void SwNavigationPI::UpdateListBox()
|
|||
m_aDocListBox->SetUpdateMode(true);
|
||||
}
|
||||
|
||||
IMPL_LINK(SwNavigationPI, DoneLink, SfxPoolItem *, pItem, void)
|
||||
IMPL_LINK(SwNavigationPI, DoneLink, SfxPoolItem const *, pItem, void)
|
||||
{
|
||||
const SfxViewFrameItem* pFrameItem = dynamic_cast<SfxViewFrameItem*>( pItem );
|
||||
const SfxViewFrameItem* pFrameItem = dynamic_cast<SfxViewFrameItem const *>( pItem );
|
||||
if( pFrameItem )
|
||||
{
|
||||
SfxViewFrame* pFrame = pFrameItem->GetFrame();
|
||||
|
|
Loading…
Reference in a new issue