Kaydet (Commit) 59935c31 authored tarafından Noel Grandin's avatar Noel Grandin

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/55671Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
üst 6b03d6f3
...@@ -118,7 +118,7 @@ private: ...@@ -118,7 +118,7 @@ private:
SvxNumberInfoItem* pNumItem; SvxNumberInfoItem* pNumItem;
SvxNumberFormatShell* pNumFmtShell; SvxNumberFormatShell* pNumFmtShell;
sal_uLong nInitFormat; sal_uLong nInitFormat;
Link<SfxPoolItem*,void> fnOkHdl; Link<SfxPoolItem const *,void> fnOkHdl;
bool bNumItemFlag; ///< for handling with DocShell bool bNumItemFlag; ///< for handling with DocShell
bool bOneAreaFlag; bool bOneAreaFlag;
......
...@@ -99,16 +99,16 @@ enum class SfxToolsModule ...@@ -99,16 +99,16 @@ enum class SfxToolsModule
class SFX2_DLLPUBLIC SfxLinkItem : public SfxPoolItem class SFX2_DLLPUBLIC SfxLinkItem : public SfxPoolItem
{ {
Link<SfxPoolItem*, void> aLink; Link<SfxPoolItem const *, void> aLink;
public: 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; } { aLink = rValue; }
virtual SfxPoolItem* Clone( SfxItemPool* = nullptr ) const override virtual SfxPoolItem* Clone( SfxItemPool* = nullptr ) const override
{ return new SfxLinkItem( *this ); } { return new SfxLinkItem( *this ); }
virtual bool operator==( const SfxPoolItem& rL) const override virtual bool operator==( const SfxPoolItem& rL) const override
{ return static_cast<const SfxLinkItem&>(rL).aLink == aLink; } { return static_cast<const SfxLinkItem&>(rL).aLink == aLink; }
const Link<SfxPoolItem*, void>& const Link<SfxPoolItem const *, void>&
GetValue() const { return aLink; } GetValue() const { return aLink; }
}; };
......
...@@ -86,7 +86,7 @@ void ScAttrDlg::PageCreated( sal_uInt16 nPageId, SfxTabPage& rTabPage ) ...@@ -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 ); GetOKButton().GetClickHdl().Call( nullptr );
} }
......
...@@ -37,7 +37,7 @@ protected: ...@@ -37,7 +37,7 @@ protected:
virtual void PageCreated( sal_uInt16 nPageId, SfxTabPage& rTabPage ) override; virtual void PageCreated( sal_uInt16 nPageId, SfxTabPage& rTabPage ) override;
private: 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_nNumberPageId;
sal_uInt16 m_nFontPageId; sal_uInt16 m_nFontPageId;
}; };
......
...@@ -1122,8 +1122,7 @@ void SfxApplication::OpenDocExec_Impl( SfxRequest& rReq ) ...@@ -1122,8 +1122,7 @@ void SfxApplication::OpenDocExec_Impl( SfxRequest& rReq )
const SfxPoolItem* pRetValue = rReq.GetReturnValue(); const SfxPoolItem* pRetValue = rReq.GetReturnValue();
if (pRetValue) if (pRetValue)
{ {
SfxPoolItem* pClone = pRetValue->Clone(); pLinkItem->GetValue().Call(pRetValue);
pLinkItem->GetValue().Call(pClone);
} }
delete pLinkItem; delete pLinkItem;
} }
......
...@@ -111,7 +111,7 @@ class SwNavigationPI : public PanelLayout, ...@@ -111,7 +111,7 @@ class SwNavigationPI : public PanelLayout,
DECL_LINK( ToolBoxDropdownClickHdl, ToolBox*, void ); DECL_LINK( ToolBoxDropdownClickHdl, ToolBox*, void );
DECL_LINK( EditAction, NumEditAction&, void ); DECL_LINK( EditAction, NumEditAction&, void );
DECL_LINK( EditGetFocus, Control&, void ); DECL_LINK( EditGetFocus, Control&, void );
DECL_LINK( DoneLink, SfxPoolItem *, void ); DECL_LINK( DoneLink, SfxPoolItem const *, void );
DECL_LINK( MenuSelectHdl, Menu *, bool ); DECL_LINK( MenuSelectHdl, Menu *, bool );
DECL_LINK( ChangePageHdl, Timer*, void ); DECL_LINK( ChangePageHdl, Timer*, void );
DECL_LINK( PageEditModifyHdl, SpinField&, void ); DECL_LINK( PageEditModifyHdl, SpinField&, void );
......
...@@ -1014,9 +1014,9 @@ void SwNavigationPI::UpdateListBox() ...@@ -1014,9 +1014,9 @@ void SwNavigationPI::UpdateListBox()
m_aDocListBox->SetUpdateMode(true); 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 ) if( pFrameItem )
{ {
SfxViewFrame* pFrame = pFrameItem->GetFrame(); SfxViewFrame* pFrame = pFrameItem->GetFrame();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment