diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-09-12 16:36:29 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-09-13 09:56:59 +0200 |
commit | cbfb7f463cbf39ec59b5a4e4f9bb07e89f8c9d13 (patch) | |
tree | a5649fe0b315c5a5dd2dc4a1ba3eef3c7c11aefd /sfx2/source/notify | |
parent | b40f41d0cfcc355f16f4a9d5b0d805fe555dd5bf (diff) |
pass SfxRequest around by std::unique_ptr
- remove a couple of copies in the process
- need to use std::function instead of LINK to handle the unique_ptr
Change-Id: Ic760d2fc639bf2e11d5bddbfbb6f2d5f15b78fe3
Reviewed-on: https://gerrit.libreoffice.org/60397
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sfx2/source/notify')
-rw-r--r-- | sfx2/source/notify/hintpost.cxx | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/sfx2/source/notify/hintpost.cxx b/sfx2/source/notify/hintpost.cxx index cd7d0653b5fa..128573280cd3 100644 --- a/sfx2/source/notify/hintpost.cxx +++ b/sfx2/source/notify/hintpost.cxx @@ -21,10 +21,11 @@ #include <arrdecl.hxx> #include <sfx2/app.hxx> +#include <sfx2/request.hxx> #include <sfxtypes.hxx> -SfxHintPoster::SfxHintPoster(const Link<SfxRequest*,void>& rLink) +SfxHintPoster::SfxHintPoster(const std::function<void (std::unique_ptr<SfxRequest>)>& rLink) : m_Link(rLink) { } @@ -33,19 +34,20 @@ SfxHintPoster::~SfxHintPoster() { } -void SfxHintPoster::Post( SfxRequest* pHintToPost ) +void SfxHintPoster::Post( std::unique_ptr<SfxRequest> pHintToPost ) { - Application::PostUserEvent( ( LINK(this, SfxHintPoster, DoEvent_Impl) ), pHintToPost ); + Application::PostUserEvent( ( LINK(this, SfxHintPoster, DoEvent_Impl) ), pHintToPost.release() ); AddFirstRef(); } IMPL_LINK( SfxHintPoster, DoEvent_Impl, void *, pPostedHint, void ) { - m_Link.Call( static_cast<SfxRequest*>(pPostedHint) ); + if (m_Link) + m_Link( std::unique_ptr<SfxRequest>(static_cast<SfxRequest*>(pPostedHint)) ); ReleaseRef(); } -void SfxHintPoster::SetEventHdl(const Link<SfxRequest*,void>& rLink) +void SfxHintPoster::SetEventHdl(const std::function<void (std::unique_ptr<SfxRequest>)>& rLink) { m_Link = rLink; } |