From a99707d2c4f65a6a5fe160ce2b614aca273f0d2d Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Mon, 8 May 2017 15:26:22 +0100 Subject: Resolves: rhbz#144437 make gnome-documents not crash the whole time MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit accept that once initted that LibreOffice cannot be deinitted and reinited (without lots of work), but allow the main loop to quit and restart so LOKs thread can run and exit successfully, new LOK connections will restart the main loop. The buckets of global state continues to be valid the whole time this way Change-Id: Ide54c0df2ce4065f7c192ae8c2cedfaaa2b58d72 Reviewed-on: https://gerrit.libreoffice.org/37399 Tested-by: Jenkins Reviewed-by: Caolán McNamara Tested-by: Caolán McNamara --- desktop/source/app/app.cxx | 2 +- desktop/source/app/officeipcthread.cxx | 9 +++++++-- desktop/source/app/officeipcthread.hxx | 2 +- desktop/source/lib/init.cxx | 5 ++++- 4 files changed, 13 insertions(+), 5 deletions(-) (limited to 'desktop') diff --git a/desktop/source/app/app.cxx b/desktop/source/app/app.cxx index c6eafe70bb46..714299e9061b 100644 --- a/desktop/source/app/app.cxx +++ b/desktop/source/app/app.cxx @@ -1996,7 +1996,7 @@ IMPL_LINK_NOARG(Desktop, OpenClients_Impl, void*, void) // When this server closes down it attempts to recreate the pipe (in RequestHandler::Disable()). // It's possible that the client has a pending connection request. // When the IPC thread is not running, this connection locks (because maPipe.accept()) is never called - RequestHandler::SetReady(); + RequestHandler::SetReady(true); OpenClients(); CloseSplashScreen(); diff --git a/desktop/source/app/officeipcthread.cxx b/desktop/source/app/officeipcthread.cxx index 7e712bc3fdd5..785cfa1d432d 100644 --- a/desktop/source/app/officeipcthread.cxx +++ b/desktop/source/app/officeipcthread.cxx @@ -932,6 +932,8 @@ void RequestHandler::Disable() handler->mIpcThread->join(); handler->mIpcThread.clear(); } + + handler->cReady.reset(); } } @@ -946,12 +948,15 @@ RequestHandler::~RequestHandler() assert(!mIpcThread.is()); } -void RequestHandler::SetReady() +void RequestHandler::SetReady(bool bIsReady) { osl::MutexGuard g(GetMutex()); if (pGlobal.is()) { - pGlobal->cReady.set(); + if (bIsReady) + pGlobal->cReady.set(); + else + pGlobal->cReady.reset(); } } diff --git a/desktop/source/app/officeipcthread.hxx b/desktop/source/app/officeipcthread.hxx index d9d70050ded6..7c24f78fcb65 100644 --- a/desktop/source/app/officeipcthread.hxx +++ b/desktop/source/app/officeipcthread.hxx @@ -122,7 +122,7 @@ class RequestHandler: public salhelper::SimpleReferenceObject static Status Enable(bool ipc); static void Disable(); // start dispatching events... - static void SetReady(); + static void SetReady(bool bIsReady); static void WaitForReady(); bool AreRequestsEnabled() const { return mState == State::RequestsEnabled; } diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx index 27af7dddca77..4003d4565df5 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -3063,10 +3063,12 @@ static void lo_startmain(void*) { osl_setThreadName("lo_startmain"); - if (GetpApp()) + if (comphelper::SolarMutex::get()) Application::GetSolarMutex().tryToAcquire(); soffice_main(); + + Application::ReleaseSolarMutex(); } static bool bInitialized = false; @@ -3233,6 +3235,7 @@ static int lo_initialize(LibreOfficeKit* pThis, const char* pAppPath, const char SAL_INFO("lok", "Enabling RequestHandler"); RequestHandler::Enable(false); SAL_INFO("lok", "Starting soffice_main"); + RequestHandler::SetReady(false); pLib->maThread = osl_createThread(lo_startmain, nullptr); SAL_INFO("lok", "Waiting for RequestHandler"); RequestHandler::WaitForReady(); -- cgit v1.2.3