[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.2' - 2 commits - include/vcl vcl/headless vcl/source

Tor Lillqvist (via logerrit) logerrit at kemper.freedesktop.org
Fri Aug 9 06:36:53 UTC 2019


 include/vcl/lok.hxx      |    1 +
 vcl/headless/svpinst.cxx |   23 +++++++++++++++++++----
 vcl/source/app/svapp.cxx |   15 ++++++++++++++-
 3 files changed, 34 insertions(+), 5 deletions(-)

New commits:
commit 76787df04dbe06a9380d7f2b9e0ca570b5517a3b
Author:     Tor Lillqvist <tml at collabora.com>
AuthorDate: Tue May 14 13:34:46 2019 +0300
Commit:     Tor Lillqvist <tml at collabora.com>
CommitDate: Fri Aug 9 08:36:19 2019 +0200

    Introduce vcl::lok::unregisterPollCallbacks() and clarify isUnipoll()
    
    There was a problem in the iOS app where a callback was done passing a
    registered mpPollClosure that pointed to the mainKit variable in
    lokit_main() even though that variable had already gone out of scope
    and been destructed.
    
    Introduce unregisterPollCallbacks(), which just sets the mpPollClosure
    pointer to null. That means no callbacks should be done any more. It
    does not mean that Unipoll would not be active. Change isUnipoll() to
    look at whether the mpPollCallback pointer has been set or not.
    
    Reviewed-on: https://gerrit.libreoffice.org/72283
    Reviewed-by: Michael Meeks <michael.meeks at collabora.com>
    Tested-by: Michael Meeks <michael.meeks at collabora.com>
    (cherry picked from commit e10cd7b8bf180ec2769ea82f537fd3bc98d2cee3)
    
    Change-Id: I5d5527c0ef097682679371dc642f8896ff05450d
    Reviewed-on: https://gerrit.libreoffice.org/77178
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
    Reviewed-by: Tor Lillqvist <tml at collabora.com>

diff --git a/include/vcl/lok.hxx b/include/vcl/lok.hxx
index 2dbc0443d7b7..7fc5479a25cd 100644
--- a/include/vcl/lok.hxx
+++ b/include/vcl/lok.hxx
@@ -21,6 +21,7 @@ namespace lok
 bool VCL_DLLPUBLIC isUnipoll();
 void VCL_DLLPUBLIC registerPollCallbacks(LibreOfficeKitPollCallback pPollCallback,
                                          LibreOfficeKitWakeCallback pWakeCallback, void* pData);
+void VCL_DLLPUBLIC unregisterPollCallbacks();
 }
 }
 
diff --git a/vcl/headless/svpinst.cxx b/vcl/headless/svpinst.cxx
index ad99d7f6f06f..48c7b46b4fd6 100644
--- a/vcl/headless/svpinst.cxx
+++ b/vcl/headless/svpinst.cxx
@@ -28,6 +28,7 @@
 #include <sal/log.hxx>
 
 #include <vcl/inputtypes.hxx>
+#include <vcl/lok.hxx>
 #ifndef LIBO_HEADLESS
 # include <vcl/opengl/OpenGLContext.hxx>
 #endif
@@ -175,7 +176,7 @@ void SvpSalInstance::Wakeup(SvpRequest const request)
 
     ImplSVData* pSVData = ImplGetSVData();
 
-    if (pSVData->mpWakeCallback)
+    if (pSVData->mpWakeCallback && pSVData->mpPollClosure)
         pSVData->mpWakeCallback(pSVData->mpPollClosure);
 
     SvpSalYieldMutex *const pMutex(static_cast<SvpSalYieldMutex*>(GetYieldMutex()));
@@ -376,8 +377,7 @@ sal_uInt32 SvpSalYieldMutex::doRelease(bool const bUnlockAll)
 
         if (isReleased)
         {
-            ImplSVData* pSVData = ImplGetSVData();
-            if (pSVData->mpPollCallback) // is unipoll
+            if (vcl::lok::isUnipoll())
             {
                 if (pInst)
                     pInst->Wakeup(SvpRequest::NONE);
@@ -471,7 +471,8 @@ bool SvpSalInstance::DoYield(bool bWait, bool bHandleAllCurrentEvents)
                     nTimeoutMS = 5000;
 
                 // External poll.
-                if (pSVData->mpPollCallback(pSVData->mpPollClosure, nTimeoutMS * 1000 /* us */) < 0)
+                if (pSVData->mpPollClosure != nullptr &&
+                    pSVData->mpPollCallback(pSVData->mpPollClosure, nTimeoutMS * 1000 /* us */) < 0)
                     pSVData->maAppData.mbAppQuit = true;
             }
             else
diff --git a/vcl/source/app/svapp.cxx b/vcl/source/app/svapp.cxx
index 5cab89a903da..a39186647741 100644
--- a/vcl/source/app/svapp.cxx
+++ b/vcl/source/app/svapp.cxx
@@ -1671,10 +1671,23 @@ void registerPollCallbacks(
     }
 }
 
+void unregisterPollCallbacks()
+{
+    ImplSVData * pSVData = ImplGetSVData();
+    if (pSVData)
+    {
+        // Just set mpPollClosure to null as that is what calling this means, that the callback data
+        // points to an object that no longer exists. In particular, don't set
+        // pSVData->mpPollCallback to nullptr as that is used to detect whether Unipoll is in use in
+        // isUnipoll().
+        pSVData->mpPollClosure = nullptr;
+    }
+}
+
 bool isUnipoll()
 {
     ImplSVData * pSVData = ImplGetSVData();
-    return pSVData && pSVData->mpPollClosure != nullptr;
+    return pSVData && pSVData->mpPollCallback != nullptr;
 }
 
 } } // namespace lok, namespace vcl
commit 8c6f86f027d9237296eb07b24f1b1dc8c53d3c6a
Author:     Michael Meeks <michael.meeks at collabora.com>
AuthorDate: Sat Apr 27 22:23:03 2019 +0100
Commit:     Tor Lillqvist <tml at collabora.com>
CommitDate: Fri Aug 9 08:36:07 2019 +0200

    unipoll: do the legacy wakeup if not in unipoll mode.
    
    Change-Id: I7f5663f3316eb2bafcf13d07e2af69ae6f0637f5
    Reviewed-on: https://gerrit.libreoffice.org/71445
    Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>
    Tested-by: Jenkins
    (cherry picked from commit 065f603379efe669d6ab496e6b8659de88949487)
    Reviewed-on: https://gerrit.libreoffice.org/77177
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
    Reviewed-by: Tor Lillqvist <tml at collabora.com>

diff --git a/vcl/headless/svpinst.cxx b/vcl/headless/svpinst.cxx
index 98cdbd6f8c6a..ad99d7f6f06f 100644
--- a/vcl/headless/svpinst.cxx
+++ b/vcl/headless/svpinst.cxx
@@ -373,8 +373,22 @@ sal_uInt32 SvpSalYieldMutex::doRelease(bool const bUnlockAll)
         // read m_nCount before doRelease
         bool const isReleased(bUnlockAll || m_nCount == 1);
         nCount = comphelper::SolarMutex::doRelease( bUnlockAll );
-        if (isReleased && pInst)
-            pInst->Wakeup(SvpRequest::NONE);
+
+        if (isReleased)
+        {
+            ImplSVData* pSVData = ImplGetSVData();
+            if (pSVData->mpPollCallback) // is unipoll
+            {
+                if (pInst)
+                    pInst->Wakeup(SvpRequest::NONE);
+            }
+            else
+            {
+                std::unique_lock<std::mutex> g(m_WakeUpMainMutex);
+                m_wakeUpMain = true;
+                m_WakeUpMainCond.notify_one();
+            }
+        }
     }
     return nCount;
 }


More information about the Libreoffice-commits mailing list