[Libreoffice-commits] core.git: include/svtools svtools/source

Noel Grandin (via logerrit) logerrit at kemper.freedesktop.org
Fri Jul 23 10:26:37 UTC 2021


 include/svtools/asynclink.hxx        |    2 -
 svtools/source/control/asynclink.cxx |   49 +++++++++++++++--------------------
 2 files changed, 22 insertions(+), 29 deletions(-)

New commits:
commit 2b2374c963bc660d8866bc17f701046ac0a03a3c
Author:     Noel Grandin <noelgrandin at gmail.com>
AuthorDate: Thu Jul 22 22:32:35 2021 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Fri Jul 23 12:25:56 2021 +0200

    simplify AsynchronLink
    
    Change-Id: Ia13e256fcd0f332c4509ea4a9b47e1b050b56443
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/119394
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/include/svtools/asynclink.hxx b/include/svtools/asynclink.hxx
index bc0c742a4b4e..3a699fe46a14 100644
--- a/include/svtools/asynclink.hxx
+++ b/include/svtools/asynclink.hxx
@@ -39,9 +39,7 @@ class UNLESS_MERGELIBS(SVT_DLLPUBLIC) AsynchronLink
     void*            _pArg;
     std::mutex       _aMutex;
 
-    DECL_DLLPRIVATE_LINK( HandleCall_Idle, Timer*, void );
     DECL_DLLPRIVATE_LINK( HandleCall_PostUserEvent, void*, void );
-    SVT_DLLPRIVATE void Call_Impl( void* pArg );
 
 public:
     AsynchronLink( const Link<void*,void>& rLink )
diff --git a/svtools/source/control/asynclink.cxx b/svtools/source/control/asynclink.cxx
index d1a111744691..e4faadfffc25 100644
--- a/svtools/source/control/asynclink.cxx
+++ b/svtools/source/control/asynclink.cxx
@@ -31,14 +31,14 @@ namespace svtools {
 void AsynchronLink::Call( void* pObj, bool bAllowDoubles )
 {
     SAL_INFO_IF( !_bInCall, "svtools", "Recursives Call. Eher ueber Timer. TLX Fragen" ); // Do NOT translate. This is a valuable historical artefact.
-    if( _aLink.IsSet() )
-    {
-        _pArg = pObj;
-        DBG_ASSERT( bAllowDoubles ||  !_nEventId, "Already made a call" );
-        ClearPendingCall();
-        std::lock_guard aGuard(_aMutex);
-        _nEventId = Application::PostUserEvent( LINK( this, AsynchronLink, HandleCall_PostUserEvent) );
-    }
+    if( !_aLink.IsSet() )
+        return;
+
+    _pArg = pObj;
+    DBG_ASSERT( bAllowDoubles ||  !_nEventId, "Already made a call" );
+    ClearPendingCall();
+    std::lock_guard aGuard(_aMutex);
+    _nEventId = Application::PostUserEvent( LINK( this, AsynchronLink, HandleCall_PostUserEvent) );
 }
 
 AsynchronLink::~AsynchronLink()
@@ -47,23 +47,8 @@ AsynchronLink::~AsynchronLink()
     {
         Application::RemoveUserEvent( _nEventId );
     }
-    if( _pDeleted ) *_pDeleted = true;
-}
-
-IMPL_LINK_NOARG( AsynchronLink, HandleCall_Idle, Timer*, void )
-{
-    {
-        std::lock_guard aGuard(_aMutex);
-        _nEventId = nullptr;
-        // need to release the lock before calling the client since
-        // the client may call back into us
-    }
-    Call_Impl( _pArg );
-}
-
-IMPL_LINK_NOARG( AsynchronLink, HandleCall_PostUserEvent, void*, void )
-{
-    HandleCall_Idle(nullptr);
+    if( _pDeleted )
+        *_pDeleted = true;
 }
 
 void AsynchronLink::ClearPendingCall()
@@ -76,12 +61,22 @@ void AsynchronLink::ClearPendingCall()
     }
 }
 
-void AsynchronLink::Call_Impl( void* pArg )
+IMPL_LINK_NOARG( AsynchronLink, HandleCall_PostUserEvent, void*, void )
 {
+    {
+        std::lock_guard aGuard(_aMutex);
+        _nEventId = nullptr;
+        // need to release the lock before calling the client since
+        // the client may call back into us
+    }
     _bInCall = true;
+
+    // some fancy footwork in case we get deleted inside the call
     bool bDeleted = false;
     _pDeleted = &bDeleted;
-    _aLink.Call( pArg );
+
+    _aLink.Call( _pArg );
+
     if( !bDeleted )
     {
         _bInCall = false;


More information about the Libreoffice-commits mailing list