[Libreoffice-commits] core.git: desktop/source

Stephan Bergmann sbergman at redhat.com
Tue Mar 29 14:03:41 UTC 2016


 desktop/source/app/app.cxx             |    2 +-
 desktop/source/app/officeipcthread.cxx |   25 ++++++++++++-------------
 desktop/source/app/officeipcthread.hxx |    3 +--
 desktop/source/lib/init.cxx            |   22 ++++++----------------
 4 files changed, 20 insertions(+), 32 deletions(-)

New commits:
commit 79b0d4ba2cbc5a35adaa9628cc18eb0f46d01f9c
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Tue Mar 29 15:59:24 2016 +0200

    Don't launch the PipeReaderThread from LOK
    
    ATTENTION: Users of LOK need to ensure somehow that no two processes operate on
    the same UserInstallation simultanously. Especially the lokdocview widget in
    gnome-documents is known to be problematic in this regard, cf. the mail thread
    starting at
    <https://lists.freedesktop.org/archives/libreoffice/2016-March/073839.html>
    "LibreOfficeKit and the UserInstallation".
    
    Change-Id: I7bc2edb281c925e479b8006151d8549441c9e9e8

diff --git a/desktop/source/app/app.cxx b/desktop/source/app/app.cxx
index 46bb168..f99bfde 100644
--- a/desktop/source/app/app.cxx
+++ b/desktop/source/app/app.cxx
@@ -576,7 +576,7 @@ void Desktop::Init()
         const CommandLineArgs& rCmdLineArgs = GetCommandLineArgs();
 
         // start ipc thread only for non-remote offices
-        RequestHandler::Status aStatus = RequestHandler::Enable();
+        RequestHandler::Status aStatus = RequestHandler::Enable(true);
         if ( aStatus == RequestHandler::IPC_STATUS_PIPE_ERROR )
         {
 #if HAVE_FEATURE_MACOSX_SANDBOX
diff --git a/desktop/source/app/officeipcthread.cxx b/desktop/source/app/officeipcthread.cxx
index 922cdaf..0b77b15 100644
--- a/desktop/source/app/officeipcthread.cxx
+++ b/desktop/source/app/officeipcthread.cxx
@@ -445,14 +445,23 @@ void RequestHandler::RequestsCompleted()
     }
 }
 
-RequestHandler::Status RequestHandler::Enable()
+RequestHandler::Status RequestHandler::Enable(bool ipc)
 {
     ::osl::MutexGuard   aGuard( GetMutex() );
 
     if( pGlobal.is() )
         return IPC_STATUS_OK;
 
-#if HAVE_FEATURE_DESKTOP
+#if !HAVE_FEATURE_DESKTOP
+    ipc = false;
+#endif
+
+    if (!ipc) {
+        rtl::Reference< RequestHandler > pThread(new RequestHandler);
+        pGlobal = pThread;
+        return IPC_STATUS_OK;
+    }
+
     OUString aUserInstallPath;
     OUString aDummy;
 
@@ -588,6 +597,7 @@ RequestHandler::Status RequestHandler::Enable()
         pThread->mPipeReaderThread = new PipeReaderThread(*pThread, pipe);
         pGlobal = pThread;
         pThread->mPipeReaderThread->launch();
+        return IPC_STATUS_OK;
     }
     else
     {
@@ -626,11 +636,6 @@ RequestHandler::Status RequestHandler::Enable()
 
         return IPC_STATUS_2ND_OFFICE;
     }
-#else
-    rtl::Reference< RequestHandler > pThread(new RequestHandler);
-    pGlobal = pThread;
-#endif
-    return IPC_STATUS_OK;
 }
 
 void RequestHandler::Disable(bool join)
@@ -694,12 +699,6 @@ void RequestHandler::WaitForReady()
     }
 }
 
-bool RequestHandler::IsEnabled()
-{
-    osl::MutexGuard g(GetMutex());
-    return pGlobal.is();
-}
-
 void PipeReaderThread::execute()
 {
 #if HAVE_FEATURE_DESKTOP
diff --git a/desktop/source/app/officeipcthread.hxx b/desktop/source/app/officeipcthread.hxx
index a21405b..7b154d5 100644
--- a/desktop/source/app/officeipcthread.hxx
+++ b/desktop/source/app/officeipcthread.hxx
@@ -115,12 +115,11 @@ class RequestHandler: public salhelper::SimpleReferenceObject
         ProcessDocumentsRequest&, bool noTerminate);
 
     // return sal_False if second office
-    static Status               Enable();
+    static Status               Enable(bool ipc);
     static void                 Disable(bool join = true);
     // start dispatching events...
     static void                 SetReady();
     static void                 WaitForReady();
-    static bool                 IsEnabled();
 
     bool                        AreRequestsEnabled() const { return mState == State::RequestsEnabled; }
 };
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 46d79d9..12d0555 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -1920,9 +1920,6 @@ static int lo_initialize(LibreOfficeKit* pThis, const char* pAppPath, const char
             force_c_locale();
         }
 
-        // This is horrible crack. I really would want to go back to simply just call
-        // InitVCL() here. The RequestHandler thing is just horrible.
-
         // We could use InitVCL() here -- and used to before using soffice_main,
         // however that now deals with the initialisation for us (and it's not
         // possible to try to set up VCL twice.
@@ -1935,28 +1932,21 @@ static int lo_initialize(LibreOfficeKit* pThis, const char* pAppPath, const char
         // if you try to use loadDocument too early.
 
         // The RequestHandler is specifically set to be ready when all the other
-        // init in Desktop::Main (run from soffice_main) is done. We can "enable"
-        // the Thread from wherever (it's done again in Desktop::Main), and can
-        // then use it to wait until we're definitely ready to continue.
+        // init in Desktop::Main (run from soffice_main) is done. We can enable
+        // the RequestHandler here (without starting any IPC thread;
+        // shortcutting the invocation in Desktop::Main that would start the IPC
+        // thread), and can then use it to wait until we're definitely ready to
+        // continue.
 
         if (eStage != PRE_INIT)
         {
             SAL_INFO("lok", "Enabling RequestHandler");
-            RequestHandler::Enable();
+            RequestHandler::Enable(false);
             SAL_INFO("lok", "Starting soffice_main");
             pLib->maThread = osl_createThread(lo_startmain, nullptr);
             SAL_INFO("lok", "Waiting for RequestHandler");
             RequestHandler::WaitForReady();
             SAL_INFO("lok", "RequestHandler ready -- continuing");
-
-            // If the Thread has been disabled again that indicates that a
-            // restart is required (or in any case we don't have a useable
-            // process around).
-            if (!RequestHandler::IsEnabled())
-            {
-                fprintf(stderr, "LOK init failed -- restart required\n");
-                return false;
-            }
         }
 
         if (eStage != SECOND_INIT)


More information about the Libreoffice-commits mailing list