[Libreoffice-commits] core.git: 3 commits - desktop/source framework/source include/vcl vcl/headless vcl/source

Tor Lillqvist (via logerrit) logerrit at kemper.freedesktop.org
Thu May 16 10:27:33 UTC 2019


 desktop/source/lib/init.cxx           |   15 +++++++++++----
 framework/source/services/desktop.cxx |    4 ++++
 include/vcl/lok.hxx                   |    1 +
 vcl/headless/svpinst.cxx              |    9 +++++----
 vcl/source/app/svapp.cxx              |   15 ++++++++++++++-
 5 files changed, 35 insertions(+), 9 deletions(-)

New commits:
commit d5c6efa206efe0ac99b136321b9ecf77c7c2392c
Author:     Tor Lillqvist <tml at collabora.com>
AuthorDate: Tue May 14 13:35:11 2019 +0300
Commit:     Tor Lillqvist <tml at collabora.com>
CommitDate: Thu May 16 13:24:42 2019 +0300

    Don't call Application::Quit() in Desktop::terminate() on iOS
    
    When exiting from a document in the iOS app, the Application::Quit()
    would post an ImplQuitMsg user event that would however not be handled
    for that document. Instead, it would be handled by the next document
    opened and thus the code would immediately stop editing the document,
    causing grief.
    
    Change-Id: Id24c843b3f329673035da55f53c2134265fce003

diff --git a/framework/source/services/desktop.cxx b/framework/source/services/desktop.cxx
index b3af82593e66..8a91db555c14 100644
--- a/framework/source/services/desktop.cxx
+++ b/framework/source/services/desktop.cxx
@@ -243,7 +243,11 @@ sal_Bool SAL_CALL Desktop::terminate()
 
     if (bRestartableMainLoop)
     {
+#ifndef IOS // or ANDROID?
+        // In the iOS app, posting the ImplQuitMsg user event will be too late, it will not be handled during the
+        // lifetime of the current document, but handled for the next document opened, which thus will break horribly.
         Application::Quit();
+#endif
         return true;
     }
     if ( ! bFramesClosed )
commit b693fb5cf154b177dd03184c789a4ef6b2aaa833
Author:     Tor Lillqvist <tml at collabora.com>
AuthorDate: Tue May 14 10:20:50 2019 +0300
Commit:     Tor Lillqvist <tml at collabora.com>
CommitDate: Thu May 16 13:24:42 2019 +0300

    We apparently need to drop the Solar Mutex when exiting lo_runLoop() on iOS
    
    It seems to be held after soffice_main() returns for the first
    document opened, but not subsequent ones, for some reason. So acquire
    it an extra time to be able to use Application::ReleaseSolarMutex()...
    
    Without this, when opening a subsequent document, the loleaflet
    loading progress bar just hangs.
    
    Change-Id: I4e4e7b814f0dba836b790b6f68470aab54f8bbb9

diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index fc4f2aa4881c..ac82e295546f 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -4524,13 +4524,20 @@ static void lo_runLoop(LibreOfficeKit* /*pThis*/,
 {
 #ifdef IOS // Maybe ANDROID, too?
     InitVCL();
+    Application::GetSolarMutex().acquire();
 #endif
 
-    SolarMutexGuard aGuard;
+    {
+        SolarMutexGuard aGuard;
 
-    vcl::lok::registerPollCallbacks(pPollCallback, pWakeCallback, pData);
-    Application::UpdateMainThread();
-    soffice_main();
+        vcl::lok::registerPollCallbacks(pPollCallback, pWakeCallback, pData);
+        Application::UpdateMainThread();
+        soffice_main();
+    }
+#ifdef IOS // ANDROID, too?
+    vcl::lok::unregisterPollCallbacks();
+    Application::ReleaseSolarMutex();
+#endif
 }
 
 static bool bInitialized = false;
commit e10cd7b8bf180ec2769ea82f537fd3bc98d2cee3
Author:     Tor Lillqvist <tml at collabora.com>
AuthorDate: Tue May 14 13:34:46 2019 +0300
Commit:     Tor Lillqvist <tml at collabora.com>
CommitDate: Thu May 16 13:24:42 2019 +0300

    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.
    
    Change-Id: I5d5527c0ef097682679371dc642f8896ff05450d
    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>

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 275ffc092735..74900df2471f 100644
--- a/vcl/headless/svpinst.cxx
+++ b/vcl/headless/svpinst.cxx
@@ -29,6 +29,7 @@
 
 #include <vcl/virdev.hxx>
 #include <vcl/inputtypes.hxx>
+#include <vcl/lok.hxx>
 #ifndef LIBO_HEADLESS
 # include <vcl/opengl/OpenGLContext.hxx>
 #endif
@@ -176,7 +177,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()));
@@ -377,8 +378,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);
@@ -472,7 +472,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 df05d78d864f..d087a1595ac6 100644
--- a/vcl/source/app/svapp.cxx
+++ b/vcl/source/app/svapp.cxx
@@ -1675,10 +1675,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


More information about the Libreoffice-commits mailing list