core.git: include/sfx2 sfx2/source

2024-03-10 Thread Hassan Sajjad (via logerrit)
 include/sfx2/dispatch.hxx|1 +
 sfx2/source/control/dispatch.cxx |4 ++--
 sfx2/source/inc/hintpost.hxx |7 ---
 sfx2/source/notify/hintpost.cxx  |   11 ---
 4 files changed, 11 insertions(+), 12 deletions(-)

New commits:
commit 0783eeba65ec51051d072b6d4c6d32b3b45bee61
Author: Hassan Sajjad 
AuthorDate: Mon Jan 29 21:00:15 2024 +0500
Commit: Hossein 
CommitDate: Mon Mar 11 00:12:30 2024 +0100

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 
Reviewed-by: Hossein 

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);
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)>() );
+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 
 #include 
 #include 
+#include 
 
 
 class SfxRequest;
@@ -41,17 +42,17 @@ class SfxRequest;
 class SfxHintPoster final : public SvRefBase
 {
 private:
-std::function)> m_Link;
+class SfxDispatcher *m_Link;
 
 DECL_LINK( DoEvent_Impl, void*, void );
 
 virtual ~SfxHintPoster() override;
 
 public:
-SfxHintPoster(std::function)> aLink);
+SfxHintPoster(SfxDispatcher *aLink);
 
 voidPost( std::unique_ptr pHint );
-voidSetEventHdl(const std::function)>& rLink);
+voidClearLink();
 };
 
 #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 
 #include 
 
-SfxHintPoster::SfxHintPoster(std::function)> 
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(pRequest));
+m_Link->PostMsgHandler(std::unique_ptr(pRequest));
 
 if (bSetView)
 {
@@ -83,9 +83,6 @@ IMPL_LINK(SfxHintPoster, DoEvent_Impl, void*, pPostedHint, 
void)
 ReleaseRef();
 }
 
-void SfxHintPoster::SetEventHdl(const 
std::function)>& rLink)
-{
-m_Link = rLink;
-}
+void SfxHintPoster::ClearLink() { m_Link = nullptr; }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */


Hassan Sajjad License Statement

2024-01-29 Thread Hassan Sajjad
   All of my past & future contributions to LibreOffice may be
   licensed under the MPLv2/LGPLv3+ dual license.


Question About Advanced UNO

2023-12-22 Thread Hassan Sajjad
Hi.

I am reading this link to get an understanding of UNO
https://wiki.documentfoundation.org/Documentation/DevGuide/Advanced_UNO

Close to the end, it is mentioned that "The disadvantage of the above
function is that it must acquire and release the *mutex* every time it is
called. The double-checked locking idiom was developed to reduce the need
for locking, leading to the following modified function. Do not use.:"

But locking is not needed in C++11 https://stackoverflow.com/a/449823.

The documentation mentions that "Implementing a UNO component that is
instantiated on demand from any other language at the global service
manager. In addition to 2) above, a binding must provide the code that
starts up the runtime engine of the target environment. For example, when a
Java UNO component is instantiated by the LibreOffice process, the Java VM
must be loaded and initialized, before the actual component is loaded
(bidirectional binding)"

 Where is the global service manager? Is it in C++? How to implement a UNO
Component in C++? How to instantiate a UNO Component at the global service
manager in C++.

Best,
Hassan Sajjad