|
|
f325b2 |
From baa91265d38ac44294b93f8ce47162454fbeb6d4 Mon Sep 17 00:00:00 2001
|
|
|
f325b2 |
From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= <caolanm@redhat.com>
|
|
|
f325b2 |
Date: Mon, 8 May 2017 15:26:22 +0100
|
|
|
f325b2 |
Subject: [PATCH] Resolves: rhbz#144437 make gnome-documents not crash the
|
|
|
f325b2 |
whole time
|
|
|
f325b2 |
|
|
|
f325b2 |
accept that once initted that LibreOffice cannot be deinitted and reinited
|
|
|
f325b2 |
(without lots of work), but allow the main loop to quit and restart so LOKs
|
|
|
f325b2 |
thread can run and exit successfully, new LOK connections will restart the main
|
|
|
f325b2 |
loop.
|
|
|
f325b2 |
|
|
|
f325b2 |
The buckets of global state continues to be valid the whole time this way
|
|
|
f325b2 |
|
|
|
f325b2 |
Change-Id: Ide54c0df2ce4065f7c192ae8c2cedfaaa2b58d72
|
|
|
f325b2 |
---
|
|
|
f325b2 |
desktop/source/app/app.cxx | 2 +-
|
|
|
f325b2 |
desktop/source/app/officeipcthread.cxx | 11 ++++++++---
|
|
|
f325b2 |
desktop/source/app/officeipcthread.hxx | 2 +-
|
|
|
f325b2 |
desktop/source/lib/init.cxx | 6 ++++++
|
|
|
f325b2 |
framework/source/services/desktop.cxx | 10 ++++++++--
|
|
|
f325b2 |
libreofficekit/source/gtk/lokdocview.cxx | 6 ++++++
|
|
|
f325b2 |
vcl/source/app/svapp.cxx | 1 +
|
|
|
f325b2 |
vcl/source/app/svmain.cxx | 8 ++++++++
|
|
|
f325b2 |
8 files changed, 39 insertions(+), 7 deletions(-)
|
|
|
f325b2 |
|
|
|
f325b2 |
diff --git a/desktop/source/app/app.cxx b/desktop/source/app/app.cxx
|
|
|
f325b2 |
index 5042752..372f605 100644
|
|
|
f325b2 |
--- a/desktop/source/app/app.cxx
|
|
|
f325b2 |
+++ b/desktop/source/app/app.cxx
|
|
|
f325b2 |
@@ -1890,7 +1890,7 @@ IMPL_LINK_NOARG(Desktop, OpenClients_Impl)
|
|
|
f325b2 |
try {
|
|
|
f325b2 |
OpenClients();
|
|
|
f325b2 |
|
|
|
f325b2 |
- OfficeIPCThread::SetReady();
|
|
|
f325b2 |
+ OfficeIPCThread::SetReady(true);
|
|
|
f325b2 |
|
|
|
f325b2 |
CloseSplashScreen();
|
|
|
f325b2 |
CheckFirstRun( );
|
|
|
f325b2 |
diff --git a/desktop/source/app/officeipcthread.cxx b/desktop/source/app/officeipcthread.cxx
|
|
|
f325b2 |
index cb6ad0b..e65e935 100644
|
|
|
f325b2 |
--- a/desktop/source/app/officeipcthread.cxx
|
|
|
f325b2 |
+++ b/desktop/source/app/officeipcthread.cxx
|
|
|
f325b2 |
@@ -646,13 +646,15 @@ void OfficeIPCThread::DisableOfficeIPCThread(bool join)
|
|
|
f325b2 |
// release mutex to avoid deadlocks
|
|
|
f325b2 |
aMutex.clear();
|
|
|
f325b2 |
|
|
|
f325b2 |
- OfficeIPCThread::SetReady(pOfficeIPCThread);
|
|
|
f325b2 |
+ OfficeIPCThread::SetReady(true, pOfficeIPCThread);
|
|
|
f325b2 |
|
|
|
f325b2 |
// exit gracefully and join
|
|
|
f325b2 |
if (join)
|
|
|
f325b2 |
{
|
|
|
f325b2 |
pOfficeIPCThread->join();
|
|
|
f325b2 |
}
|
|
|
f325b2 |
+
|
|
|
f325b2 |
+ OfficeIPCThread::SetReady(false, pOfficeIPCThread);
|
|
|
f325b2 |
}
|
|
|
f325b2 |
}
|
|
|
f325b2 |
|
|
|
f325b2 |
@@ -675,14 +677,17 @@ OfficeIPCThread::~OfficeIPCThread()
|
|
|
f325b2 |
pGlobalOfficeIPCThread.clear();
|
|
|
f325b2 |
}
|
|
|
f325b2 |
|
|
|
f325b2 |
-void OfficeIPCThread::SetReady(
|
|
|
f325b2 |
+void OfficeIPCThread::SetReady(bool bIsReady,
|
|
|
f325b2 |
rtl::Reference< OfficeIPCThread > const & pThread)
|
|
|
f325b2 |
{
|
|
|
f325b2 |
rtl::Reference< OfficeIPCThread > const & t(
|
|
|
f325b2 |
pThread.is() ? pThread : pGlobalOfficeIPCThread);
|
|
|
f325b2 |
if (t.is())
|
|
|
f325b2 |
{
|
|
|
f325b2 |
- t->cReady.set();
|
|
|
f325b2 |
+ if (bIsReady)
|
|
|
f325b2 |
+ t->cReady.set();
|
|
|
f325b2 |
+ else
|
|
|
f325b2 |
+ t->cReady.reset();
|
|
|
f325b2 |
}
|
|
|
f325b2 |
}
|
|
|
f325b2 |
|
|
|
f325b2 |
diff --git a/desktop/source/app/officeipcthread.hxx b/desktop/source/app/officeipcthread.hxx
|
|
|
f325b2 |
index e81f57a..f23eff2 100644
|
|
|
f325b2 |
--- a/desktop/source/app/officeipcthread.hxx
|
|
|
f325b2 |
+++ b/desktop/source/app/officeipcthread.hxx
|
|
|
f325b2 |
@@ -115,7 +115,7 @@ class OfficeIPCThread : public salhelper::Thread
|
|
|
f325b2 |
static Status EnableOfficeIPCThread();
|
|
|
f325b2 |
static void DisableOfficeIPCThread(bool join = true);
|
|
|
f325b2 |
// start dispatching events...
|
|
|
f325b2 |
- static void SetReady(
|
|
|
f325b2 |
+ static void SetReady(bool bIsReady,
|
|
|
f325b2 |
rtl::Reference< OfficeIPCThread > const & pThread =
|
|
|
f325b2 |
rtl::Reference< OfficeIPCThread >());
|
|
|
f325b2 |
static void WaitForReady(
|
|
|
f325b2 |
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
|
|
|
f325b2 |
index 184d777..2619539 100644
|
|
|
f325b2 |
--- a/desktop/source/lib/init.cxx
|
|
|
f325b2 |
+++ b/desktop/source/lib/init.cxx
|
|
|
f325b2 |
@@ -1697,7 +1697,12 @@ static void lo_startmain(void*)
|
|
|
f325b2 |
{
|
|
|
f325b2 |
osl_setThreadName("lo_startmain");
|
|
|
f325b2 |
|
|
|
f325b2 |
+ if (comphelper::SolarMutex::get())
|
|
|
f325b2 |
+ Application::GetSolarMutex().tryToAcquire();
|
|
|
f325b2 |
+
|
|
|
f325b2 |
soffice_main();
|
|
|
f325b2 |
+
|
|
|
f325b2 |
+ Application::ReleaseSolarMutex();
|
|
|
f325b2 |
}
|
|
|
f325b2 |
|
|
|
f325b2 |
static bool bInitialized = false;
|
|
|
f325b2 |
@@ -1799,6 +1804,7 @@ static int lo_initialize(LibreOfficeKit* pThis, const char* pAppPath, const char
|
|
|
f325b2 |
SAL_INFO("lok", "Enabling OfficeIPCThread");
|
|
|
f325b2 |
OfficeIPCThread::EnableOfficeIPCThread();
|
|
|
f325b2 |
SAL_INFO("lok", "Starting soffice_main");
|
|
|
f325b2 |
+ OfficeIPCThread::SetReady(false);
|
|
|
f325b2 |
pLib->maThread = osl_createThread(lo_startmain, NULL);
|
|
|
f325b2 |
SAL_INFO("lok", "Waiting for OfficeIPCThread");
|
|
|
f325b2 |
OfficeIPCThread::WaitForReady();
|
|
|
f325b2 |
diff --git a/framework/source/services/desktop.cxx b/framework/source/services/desktop.cxx
|
|
|
f325b2 |
index 24b9761..c7dbaca 100644
|
|
|
f325b2 |
--- a/framework/source/services/desktop.cxx
|
|
|
f325b2 |
+++ b/framework/source/services/desktop.cxx
|
|
|
f325b2 |
@@ -59,6 +59,7 @@
|
|
|
f325b2 |
#include <com/sun/star/frame/XTerminateListener2.hpp>
|
|
|
f325b2 |
|
|
|
f325b2 |
#include <comphelper/sequence.hxx>
|
|
|
f325b2 |
+#include <comphelper/lok.hxx>
|
|
|
f325b2 |
#include <cppuhelper/supportsservice.hxx>
|
|
|
f325b2 |
#include <vcl/svapp.hxx>
|
|
|
f325b2 |
|
|
|
f325b2 |
@@ -231,8 +232,13 @@ sal_Bool SAL_CALL Desktop::terminate()
|
|
|
f325b2 |
|
|
|
f325b2 |
// try to close all open frames.
|
|
|
f325b2 |
// Allow using of any UI ... because Desktop.terminate() was designed as UI functionality in the past.
|
|
|
f325b2 |
- bool bAllowUI = true;
|
|
|
f325b2 |
- bool bFramesClosed = impl_closeFrames(bAllowUI);
|
|
|
f325b2 |
+ bool bRestartableMainLoop = comphelper::LibreOfficeKit::isActive();
|
|
|
f325b2 |
+ bool bFramesClosed = impl_closeFrames(!bRestartableMainLoop);
|
|
|
f325b2 |
+ if (bRestartableMainLoop)
|
|
|
f325b2 |
+ {
|
|
|
f325b2 |
+ Application::Quit();
|
|
|
f325b2 |
+ return true;
|
|
|
f325b2 |
+ }
|
|
|
f325b2 |
if ( ! bFramesClosed )
|
|
|
f325b2 |
{
|
|
|
f325b2 |
impl_sendCancelTerminationEvent(lCalledTerminationListener);
|
|
|
f325b2 |
diff --git a/libreofficekit/source/gtk/lokdocview.cxx b/libreofficekit/source/gtk/lokdocview.cxx
|
|
|
f325b2 |
index 7d1ec01..92cf6b3 100644
|
|
|
f325b2 |
--- a/libreofficekit/source/gtk/lokdocview.cxx
|
|
|
f325b2 |
+++ b/libreofficekit/source/gtk/lokdocview.cxx
|
|
|
f325b2 |
@@ -2051,9 +2051,15 @@ static void lok_doc_view_destroy (GtkWidget* widget)
|
|
|
f325b2 |
LOKDocViewPrivate& priv = getPrivate(pDocView);
|
|
|
f325b2 |
|
|
|
f325b2 |
if (priv->m_pDocument)
|
|
|
f325b2 |
+ {
|
|
|
f325b2 |
priv->m_pDocument->pClass->destroy (priv->m_pDocument);
|
|
|
f325b2 |
+ priv->m_pDocument = nullptr;
|
|
|
f325b2 |
+ }
|
|
|
f325b2 |
if (priv->m_pOffice)
|
|
|
f325b2 |
+ {
|
|
|
f325b2 |
priv->m_pOffice->pClass->destroy (priv->m_pOffice);
|
|
|
f325b2 |
+ priv->m_pOffice = nullptr;
|
|
|
f325b2 |
+ }
|
|
|
f325b2 |
|
|
|
f325b2 |
GTK_WIDGET_CLASS (lok_doc_view_parent_class)->destroy (widget);
|
|
|
f325b2 |
}
|
|
|
f325b2 |
diff --git a/vcl/source/app/svapp.cxx b/vcl/source/app/svapp.cxx
|
|
|
f325b2 |
index 302c4a7..2104243 100644
|
|
|
f325b2 |
--- a/vcl/source/app/svapp.cxx
|
|
|
f325b2 |
+++ b/vcl/source/app/svapp.cxx
|
|
|
f325b2 |
@@ -331,6 +331,7 @@ void Application::Execute()
|
|
|
f325b2 |
{
|
|
|
f325b2 |
ImplSVData* pSVData = ImplGetSVData();
|
|
|
f325b2 |
pSVData->maAppData.mbInAppExecute = true;
|
|
|
f325b2 |
+ pSVData->maAppData.mbAppQuit = false;
|
|
|
f325b2 |
|
|
|
f325b2 |
while ( !pSVData->maAppData.mbAppQuit )
|
|
|
f325b2 |
Application::Yield();
|
|
|
f325b2 |
diff --git a/vcl/source/app/svmain.cxx b/vcl/source/app/svmain.cxx
|
|
|
f325b2 |
index f6d4e25..16977d3 100644
|
|
|
f325b2 |
--- a/vcl/source/app/svmain.cxx
|
|
|
f325b2 |
+++ b/vcl/source/app/svmain.cxx
|
|
|
f325b2 |
@@ -28,6 +28,7 @@
|
|
|
f325b2 |
#include "tools/resmgr.hxx"
|
|
|
f325b2 |
|
|
|
f325b2 |
#include "comphelper/processfactory.hxx"
|
|
|
f325b2 |
+#include "comphelper/lok.hxx"
|
|
|
f325b2 |
|
|
|
f325b2 |
#include "unotools/syslocaleoptions.hxx"
|
|
|
f325b2 |
#include "vcl/svapp.hxx"
|
|
|
f325b2 |
@@ -343,6 +344,13 @@ VCLUnoWrapperDeleter::disposing(lang::EventObject const& /* rSource */)
|
|
|
f325b2 |
|
|
|
f325b2 |
void DeInitVCL()
|
|
|
f325b2 |
{
|
|
|
f325b2 |
+ //rhbz#1444437, when using LibreOffice like a library you can't realistically
|
|
|
f325b2 |
+ //tear everything down and recreate them on the next call, there's too many
|
|
|
f325b2 |
+ //(c++) singletons that point to stuff that gets deleted during shutdown
|
|
|
f325b2 |
+ //which won't be recreated on restart.
|
|
|
f325b2 |
+ if (comphelper::LibreOfficeKit::isActive())
|
|
|
f325b2 |
+ return;
|
|
|
f325b2 |
+
|
|
|
f325b2 |
ImplSVData* pSVData = ImplGetSVData();
|
|
|
f325b2 |
pSVData->mbDeInit = true;
|
|
|
f325b2 |
|
|
|
f325b2 |
--
|
|
|
f325b2 |
1.8.3.1
|
|
|
f325b2 |
|