summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHassan Sajjad <hassan.sajjad069@gmail.com>2024-01-29 21:00:15 +0500
committerHossein <hossein@libreoffice.org>2024-03-11 00:12:30 +0100
commit0783eeba65ec51051d072b6d4c6d32b3b45bee61 (patch)
tree5721ffc358cd548ca48c8677f37b28710a0a0ebd
parentcc695e180b39ffe21f0ae12cfeefb89a50a50b64 (diff)
Remove redundant function indirection in SfxHintPoster
SfxHintPoster::mLink always pointed to SfxDispatcher::PostMsgHandler and except in ~SfxDispatcher, it was reinitialized to empty i.e. cleared. This extra indirection is now removed. SfxHintPoster was using SvRefBase to persist even after SfxDispatcher was deleted and then deleted itself after SfxHintPoster::Post call was completed. This extra indirection was adding 4-5 frames while debugging. Change-Id: Ibfd6d3aea10ddf45732adc1a9d63a25717a771fa Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162700 Tested-by: Hossein <hossein@libreoffice.org> Reviewed-by: Hossein <hossein@libreoffice.org>
-rw-r--r--include/sfx2/dispatch.hxx1
-rw-r--r--sfx2/source/control/dispatch.cxx4
-rw-r--r--sfx2/source/inc/hintpost.hxx7
-rw-r--r--sfx2/source/notify/hintpost.cxx11
4 files changed, 11 insertions, 12 deletions
diff --git a/include/sfx2/dispatch.hxx b/include/sfx2/dispatch.hxx
index 7216fc92badc..eea69d2a5abc 100644
--- a/include/sfx2/dispatch.hxx
+++ b/include/sfx2/dispatch.hxx
@@ -80,6 +80,7 @@ friend class SfxBindings;
friend class SfxStateCache;
friend class SfxPopupMenuManager;
friend class SfxHelp;
+friend class SfxHintPoster;
DECL_DLLPRIVATE_LINK( EventHdl_Impl, Timer *, void );
void PostMsgHandler(std::unique_ptr<SfxRequest>);
diff --git a/sfx2/source/control/dispatch.cxx b/sfx2/source/control/dispatch.cxx
index ccb0b0802f42..a780892b6940 100644
--- a/sfx2/source/control/dispatch.cxx
+++ b/sfx2/source/control/dispatch.cxx
@@ -303,7 +303,7 @@ void SfxDispatcher::Construct_Impl()
for (SfxObjectBars_Impl & rObjBar : xImp->aObjBars)
rObjBar.eId = ToolbarId::None;
- xImp->xPoster = new SfxHintPoster(std::bind(&SfxDispatcher::PostMsgHandler, this, std::placeholders::_1));
+ xImp->xPoster = new SfxHintPoster(this);
xImp->aIdle.SetPriority(TaskPriority::HIGH_IDLE );
xImp->aIdle.SetInvokeHandler( LINK(this, SfxDispatcher, EventHdl_Impl ) );
@@ -335,7 +335,7 @@ SfxDispatcher::~SfxDispatcher()
// So that no timer by Reschedule in PlugComm strikes the LeaveRegistrations
xImp->aIdle.Stop();
- xImp->xPoster->SetEventHdl( std::function<void (std::unique_ptr<SfxRequest>)>() );
+ xImp->xPoster->ClearLink();
// Notify the stack variables in Call_Impl
if ( xImp->pInCallAliveFlag )
diff --git a/sfx2/source/inc/hintpost.hxx b/sfx2/source/inc/hintpost.hxx
index ac37fde446ed..cca12647a283 100644
--- a/sfx2/source/inc/hintpost.hxx
+++ b/sfx2/source/inc/hintpost.hxx
@@ -23,6 +23,7 @@
#include <tools/ref.hxx>
#include <functional>
#include <memory>
+#include <sfx2/dispatch.hxx>
class SfxRequest;
@@ -41,17 +42,17 @@ class SfxRequest;
class SfxHintPoster final : public SvRefBase
{
private:
- std::function<void (std::unique_ptr<SfxRequest>)> m_Link;
+ class SfxDispatcher *m_Link;
DECL_LINK( DoEvent_Impl, void*, void );
virtual ~SfxHintPoster() override;
public:
- SfxHintPoster(std::function<void (std::unique_ptr<SfxRequest>)> aLink);
+ SfxHintPoster(SfxDispatcher *aLink);
void Post( std::unique_ptr<SfxRequest> pHint );
- void SetEventHdl(const std::function<void (std::unique_ptr<SfxRequest>)>& rLink);
+ void ClearLink();
};
#endif
diff --git a/sfx2/source/notify/hintpost.cxx b/sfx2/source/notify/hintpost.cxx
index 78c8c0499099..25d650de8ef2 100644
--- a/sfx2/source/notify/hintpost.cxx
+++ b/sfx2/source/notify/hintpost.cxx
@@ -25,8 +25,8 @@
#include <vcl/svapp.hxx>
#include <comphelper/lok.hxx>
-SfxHintPoster::SfxHintPoster(std::function<void(std::unique_ptr<SfxRequest>)> aLink)
- : m_Link(std::move(aLink))
+SfxHintPoster::SfxHintPoster(SfxDispatcher* aLink)
+ : m_Link(aLink)
{
}
@@ -71,7 +71,7 @@ IMPL_LINK(SfxHintPoster, DoEvent_Impl, void*, pPostedHint, void)
}
}
- m_Link(std::unique_ptr<SfxRequest>(pRequest));
+ m_Link->PostMsgHandler(std::unique_ptr<SfxRequest>(pRequest));
if (bSetView)
{
@@ -83,9 +83,6 @@ IMPL_LINK(SfxHintPoster, DoEvent_Impl, void*, pPostedHint, void)
ReleaseRef();
}
-void SfxHintPoster::SetEventHdl(const std::function<void(std::unique_ptr<SfxRequest>)>& rLink)
-{
- m_Link = rLink;
-}
+void SfxHintPoster::ClearLink() { m_Link = nullptr; }
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */