desktop/source/app/officeipcthread.cxx | 12 ++++++++++ desktop/source/app/officeipcthread.hxx | 3 ++ desktop/source/lib/init.cxx | 38 ++++++++++++++++++--------------- 3 files changed, 36 insertions(+), 17 deletions(-)
New commits: commit 6942d9b6ae3c3a8802fadf16feacd5984f55b273 Author: Andrzej Hunt <andrzej.h...@collabora.com> Date: Fri Jul 18 10:02:48 2014 +0200 Use OfficeIPCThread::WaitForReady rather than sleeping. This way we actually continue when we're ready to, rather than dumbly hoping we wait for long enough. This isn't entirely unproblematic though -- if we have no config pre-prepared (i.e. first-run), then we just end up hanging on this since soffice_main exits without doing anything to the OfficeIPCThread. (Which is especially problematic for unit tests which specifically run on an empty config.) Change-Id: I064fb500a224cfe37a0d3ba24b6154ffd72a71a3 diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx index 0be5f8d..76d05f3 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -60,8 +60,10 @@ // We also need to hackily be able to start the main libreoffice thread #include "../app/sofficemain.h" +#include "../app/officeipcthread.hxx" using namespace css; +using namespace desktop; using namespace utl; using namespace boost; @@ -637,22 +639,27 @@ static int lo_initialize(LibreOfficeKit* pThis, const char* pAppPath) // Force headless -- this is only for bitmap rendering. rtl::Bootstrap::set("SAL_USE_VCLPLUGIN", "svp"); -// InitVCL(); - // InitVCL() happens in soffice_main for us -- and we can't call InitVCL twice - // unfortunately -- which is annoying since (see below) + // 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. + + // Instead VCL init is done for us by soffice_main in a separate thread, + // however we specifically can't proceed until this setup is complete + // (or you get segfaults trying to use VCL and/or deadlocks due to other + // setup within soffice_main). Specifically the various Application:: + // functions depend on VCL being ready -- the deadlocks would happen + // if you try to use loadDocument too early. + + // The OfficeIPCThread is specifically set to be read 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. + + OfficeIPCThread::EnableOfficeIPCThread(); pthread_t thread; pthread_create(&thread, 0, lo_startmain, NULL); - sleep(10); - // We'll segfault trying to access Application if we're too fast... - // Specifically pImplSVData doesn't exist until InitVCL has been called, - // and that won't be immediate, but we can't call InitVCL ourselves - // as soffice_main already does so, but InitVCL would then fail - // within soffice_main if we have already called it earlier. - // - // And there's also a chance of deadlock if we try to open documents - // too early -- when running in a debugger we therefore need quite - // a large delay here (for now). + OfficeIPCThread::WaitForReady(); Application::EnableHeadlessMode(true); commit 13c5fb87f76655e7aa05040a4c737843561d1f44 Author: Andrzej Hunt <andrzej.h...@collabora.com> Date: Fri Jul 18 10:00:42 2014 +0200 Bin outdated / incorrect comment. Change-Id: I7b8f97377b9606a2228f172f772d8051a64703d2 diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx index e9a1eed..0be5f8d 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -635,10 +635,7 @@ static int lo_initialize(LibreOfficeKit* pThis, const char* pAppPath) initialize_uno(aAppURL); force_c_locale(); - // Force headless - // the "svp" headless vcl backend isn't able to do tiled rendering for - // us -- we need to use a full featured backend, i.e. "gen" or "gtk", - // gtk seems to be somewhat better. + // Force headless -- this is only for bitmap rendering. rtl::Bootstrap::set("SAL_USE_VCLPLUGIN", "svp"); // InitVCL(); // InitVCL() happens in soffice_main for us -- and we can't call InitVCL twice commit 2dbf8c516f880e3ba9f5025a619a5729b6342112 Author: Andrzej Hunt <andrzej.h...@collabora.com> Date: Fri Jul 18 09:48:47 2014 +0200 Add OfficeIPCThread::WaitForReady. For LibreOfficeKit we need to start up the event loop, and can't continue initialisation until all the related (VCL etc.) setup is complete -- the OfficeIPCThread is also enabled as one of the last items, and can be used to indicate whether or not we can start actually working with VCL. Change-Id: I0450b65584ddf6e8d02ce0c6e66e06f47841d1b7 diff --git a/desktop/source/app/officeipcthread.cxx b/desktop/source/app/officeipcthread.cxx index aed17b9..93cd339 100644 --- a/desktop/source/app/officeipcthread.cxx +++ b/desktop/source/app/officeipcthread.cxx @@ -669,6 +669,18 @@ void OfficeIPCThread::SetReady( } } +void OfficeIPCThread::WaitForReady( + rtl::Reference< OfficeIPCThread > const & pThread) + +{ + rtl::Reference< OfficeIPCThread > const & t( + pThread.is() ? pThread : pGlobalOfficeIPCThread); + if (t.is()) + { + t->cReady.wait(); + } +} + void OfficeIPCThread::execute() { #if HAVE_FEATURE_DESKTOP diff --git a/desktop/source/app/officeipcthread.hxx b/desktop/source/app/officeipcthread.hxx index 4628eca..9c1d751 100644 --- a/desktop/source/app/officeipcthread.hxx +++ b/desktop/source/app/officeipcthread.hxx @@ -125,6 +125,9 @@ class OfficeIPCThread : public salhelper::Thread static void SetReady( rtl::Reference< OfficeIPCThread > const & pThread = rtl::Reference< OfficeIPCThread >()); + static void WaitForReady( + rtl::Reference< OfficeIPCThread > const & pThread = + rtl::Reference< OfficeIPCThread >()); bool AreRequestsEnabled() const { return mbRequestsEnabled && ! mbDowning; } }; _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits