summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--desktop/source/app/app.cxx2
-rw-r--r--desktop/source/app/officeipcthread.cxx9
-rw-r--r--desktop/source/app/officeipcthread.hxx2
-rw-r--r--desktop/source/lib/init.cxx5
-rw-r--r--framework/source/services/desktop.cxx8
-rw-r--r--libreofficekit/source/gtk/lokdocview.cxx34
-rw-r--r--vcl/source/app/svmain.cxx8
7 files changed, 49 insertions, 19 deletions
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();
diff --git a/framework/source/services/desktop.cxx b/framework/source/services/desktop.cxx
index 477f166d3b41..ea0d610361ae 100644
--- a/framework/source/services/desktop.cxx
+++ b/framework/source/services/desktop.cxx
@@ -61,6 +61,7 @@
#include <com/sun/star/frame/XTerminateListener2.hpp>
#include <comphelper/sequence.hxx>
+#include <comphelper/lok.hxx>
#include <cppuhelper/supportsservice.hxx>
#include <rtl/instance.hxx>
#include <vcl/svapp.hxx>
@@ -227,8 +228,9 @@ sal_Bool SAL_CALL Desktop::terminate()
// try to close all open frames.
// Allow using of any UI ... because Desktop.terminate() was designed as UI functionality in the past.
- bool bIsEventTestingMode = Application::IsEventTestingModeEnabled();
- bool bFramesClosed = impl_closeFrames(!bIsEventTestingMode);
+ bool bRestartableMainLoop = Application::IsEventTestingModeEnabled() ||
+ comphelper::LibreOfficeKit::isActive();
+ bool bFramesClosed = impl_closeFrames(!bRestartableMainLoop);
// Ask normal terminate listener. They could stop terminating the process.
Desktop::TTerminateListenerList lCalledTerminationListener;
@@ -240,7 +242,7 @@ sal_Bool SAL_CALL Desktop::terminate()
return false;
}
- if (bIsEventTestingMode)
+ if (bRestartableMainLoop)
{
Application::Quit();
return true;
diff --git a/libreofficekit/source/gtk/lokdocview.cxx b/libreofficekit/source/gtk/lokdocview.cxx
index 65c5a64111f6..fd367052ddca 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -2608,20 +2608,32 @@ static void lok_doc_view_destroy (GtkWidget* widget)
std::stringstream ss;
ss << "lok::Document::setView(" << priv->m_nViewId << ")";
g_info("%s", ss.str().c_str());
- priv->m_pDocument->pClass->setView(priv->m_pDocument, priv->m_nViewId);
- priv->m_pDocument->pClass->registerCallback(priv->m_pDocument, nullptr, nullptr);
- aGuard.unlock();
-
- if (priv->m_pDocument && priv->m_pDocument->pClass->getViewsCount(priv->m_pDocument) > 1)
+ if (priv->m_pDocument)
{
- priv->m_pDocument->pClass->destroyView(priv->m_pDocument, priv->m_nViewId);
+ priv->m_pDocument->pClass->setView(priv->m_pDocument, priv->m_nViewId);
+ priv->m_pDocument->pClass->registerCallback(priv->m_pDocument, nullptr, nullptr);
}
- else
+ aGuard.unlock();
+
+ if (priv->m_pDocument)
{
- if (priv->m_pDocument)
- priv->m_pDocument->pClass->destroy (priv->m_pDocument);
- if (priv->m_pOffice)
- priv->m_pOffice->pClass->destroy (priv->m_pOffice);
+ if (priv->m_pDocument->pClass->getViewsCount(priv->m_pDocument) > 1)
+ {
+ priv->m_pDocument->pClass->destroyView(priv->m_pDocument, priv->m_nViewId);
+ }
+ else
+ {
+ if (priv->m_pDocument)
+ {
+ priv->m_pDocument->pClass->destroy (priv->m_pDocument);
+ priv->m_pDocument = nullptr;
+ }
+ if (priv->m_pOffice)
+ {
+ priv->m_pOffice->pClass->destroy (priv->m_pOffice);
+ priv->m_pOffice = nullptr;
+ }
+ }
}
GTK_WIDGET_CLASS (lok_doc_view_parent_class)->destroy (widget);
diff --git a/vcl/source/app/svmain.cxx b/vcl/source/app/svmain.cxx
index 124b11b481ef..2a89d80f60f3 100644
--- a/vcl/source/app/svmain.cxx
+++ b/vcl/source/app/svmain.cxx
@@ -90,6 +90,7 @@
#include <com/sun/star/lang/XComponent.hpp>
#include <com/sun/star/frame/Desktop.hpp>
+#include <comphelper/lok.hxx>
#include <cppuhelper/implbase.hxx>
#include <uno/current_context.hxx>
@@ -376,6 +377,13 @@ VCLUnoWrapperDeleter::disposing(lang::EventObject const& /* rSource */)
void DeInitVCL()
{
+ //rhbz#1444437, when using LibreOffice like a library you can't realistically
+ //tear everything down and recreate them on the next call, there's too many
+ //(c++) singletons that point to stuff that gets deleted during shutdown
+ //which won't be recreated on restart.
+ if (comphelper::LibreOfficeKit::isActive())
+ return;
+
{
SolarMutexReleaser r; // unblock threads blocked on that so we can join
::comphelper::JoinAsyncEventNotifiers();