desktop/source/lib/init.cxx                        |   15 ++++++++++++---
 framework/inc/helper/statusindicatorfactory.hxx    |    9 ++++++++-
 framework/source/helper/statusindicatorfactory.cxx |   11 +++++++++++
 3 files changed, 31 insertions(+), 4 deletions(-)

New commits:
commit de6eb21968c3e24b16ff3025ea5be995aa39fd91
Author:     Michael Meeks <michael.me...@collabora.com>
AuthorDate: Fri May 24 21:45:44 2024 +0100
Commit:     Andras Timar <andras.ti...@collabora.com>
CommitDate: Mon Jun 17 17:21:30 2024 +0200

    cool#9082 - lok: cleanup WakeUpThread before forking, then re-start.
    
    It seems likely that this lingering briefly after various un-identified
    and tough to reproduce, longer running operations in calc - which is a
    big ScProgress user - caused problems with background save.
    
    Change-Id: I1d0ec56c759dff30c48c8562b6400b57be4a25b2
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/168033
    Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com>
    Tested-by: Caolán McNamara <caolan.mcnam...@collabora.com>

diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 86f0efda8857..b056ba0b6407 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -3391,9 +3391,6 @@ static int lo_joinThreads(LibreOfficeKit* /* pThis */)
     comphelper::ThreadPool &pool = 
comphelper::ThreadPool::getSharedOptimalPool();
     pool.joinThreadsIfIdle();
 
-//    if (comphelper::getWorkerCount() > 0)
-//        return 0;
-
     // Grammar checker thread
     css::uno::Reference<css::linguistic2::XLinguServiceManager2> xLangSrv =
         css::linguistic2::LinguServiceManager::create(xContext);
@@ -3408,6 +3405,12 @@ static int lo_joinThreads(LibreOfficeKit* /* pThis */)
     if (joinable && !joinable->joinThreads())
         return 0;
 
+    auto progressThread = 
xContext->getServiceManager()->createInstanceWithContext(
+        "com.sun.star.task.StatusIndicatorFactory", xContext);
+    joinable = dynamic_cast<comphelper::LibreOfficeKit::ThreadJoinable 
*>(progressThread.get());
+    if (joinable && !joinable->joinThreads())
+        return 0;
+
     // Ensure configmgr's write thread is down
     css::uno::Reference< css::util::XFlushable >(
         css::configuration::theDefaultProvider::get(
@@ -3424,6 +3427,12 @@ static void lo_startThreads(LibreOfficeKit* /* pThis */)
     auto joinable = dynamic_cast<comphelper::LibreOfficeKit::ThreadJoinable 
*>(ucpWebdav.get());
     if (joinable)
         joinable->startThreads();
+
+    auto progressThread = 
xContext->getServiceManager()->createInstanceWithContext(
+        "com.sun.star.task.StatusIndicatorFactory", xContext);
+    joinable = dynamic_cast<comphelper::LibreOfficeKit::ThreadJoinable 
*>(progressThread.get());
+    if (joinable)
+        joinable->startThreads();
 }
 
 static void lo_setForkedChild(LibreOfficeKit* /* pThis */, bool bIsChild)
diff --git a/framework/inc/helper/statusindicatorfactory.hxx 
b/framework/inc/helper/statusindicatorfactory.hxx
index 08f31aa87ada..fc13002b3532 100644
--- a/framework/inc/helper/statusindicatorfactory.hxx
+++ b/framework/inc/helper/statusindicatorfactory.hxx
@@ -39,6 +39,7 @@
 
 #include <cppuhelper/supportsservice.hxx>
 #include <cppuhelper/implbase.hxx>
+#include <comphelper/lok.hxx>
 #include <rtl/ref.hxx>
 
 namespace framework{
@@ -120,7 +121,8 @@ class StatusIndicatorFactory final : public  
::cppu::WeakImplHelper<
                                              css::lang::XServiceInfo
                                            , css::lang::XInitialization
                                            , css::task::XStatusIndicatorFactory
-                                           , css::util::XUpdatable >
+                                           , css::util::XUpdatable >,
+                                     public 
comphelper::LibreOfficeKit::ThreadJoinable
 {
 
     // member
@@ -211,6 +213,11 @@ class StatusIndicatorFactory final : public  
::cppu::WeakImplHelper<
         void setValue(const css::uno::Reference< css::task::XStatusIndicator 
>& xChild,
                                              sal_Int32                         
                  nValue);
 
+        // comphelper::LibreOfficeKit::ThreadJoinable
+        virtual bool joinThreads() override;
+
+        virtual void startThreads() override;
+
     // specials
 
     private:
diff --git a/framework/source/helper/statusindicatorfactory.cxx 
b/framework/source/helper/statusindicatorfactory.cxx
index 879bd8597b33..4f5bb645f82d 100644
--- a/framework/source/helper/statusindicatorfactory.cxx
+++ b/framework/source/helper/statusindicatorfactory.cxx
@@ -286,6 +286,17 @@ void StatusIndicatorFactory::setValue( const 
css::uno::Reference< css::task::XSt
     impl_reschedule(false);
 }
 
+bool StatusIndicatorFactory::joinThreads()
+{
+    WakeUpThread::joinThread();
+    return true;
+}
+
+void StatusIndicatorFactory::startThreads()
+{
+    WakeUpThread::startThread();
+}
+
 void StatusIndicatorFactory::implts_makeParentVisibleIfAllowed()
 {
     css::uno::Reference< css::frame::XFrame > xFrame;

Reply via email to