This is an automated email from the ASF dual-hosted git repository.

jimjag pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/openoffice.git


The following commit(s) were added to refs/heads/trunk by this push:
     new 3a0630bdd7 Run the report and Calc data source warm-up loads on our 
main thread
3a0630bdd7 is described below

commit 3a0630bdd7a494db803a60f9f8c27232168f1b68
Author: Jim Jagielski <[email protected]>
AuthorDate: Thu Oct 22 10:16:25 2026 -0400

    Run the report and Calc data source warm-up loads on our main thread
    
    As detached threads they could outlive DeInitVCL and crash when the office 
terminated right after the first report or Calc data source load.
---
 main/dbaccess/source/filter/xml/xmlfilter.cxx      | 12 +++++++-
 .../source/core/api/ReportDefinition.cxx           | 32 +++++++++++-----------
 2 files changed, 27 insertions(+), 17 deletions(-)

diff --git a/main/dbaccess/source/filter/xml/xmlfilter.cxx 
b/main/dbaccess/source/filter/xml/xmlfilter.cxx
index a29fc19aa8..92f7e89cb2 100644
--- a/main/dbaccess/source/filter/xml/xmlfilter.cxx
+++ b/main/dbaccess/source/filter/xml/xmlfilter.cxx
@@ -154,6 +154,10 @@ namespace dbaxml
                 ,m_eWhat(_eType)
                    {}
 
+            // E_CALC runs as a main-thread user event: as a detached thread 
it could outlive
+            // DeInitVCL, and its frame creation then restarted VCL while the 
office was exiting.
+            DECL_STATIC_LINK( FastLoader, RunHdl, FastLoader* );
+
            protected:
             virtual ~FastLoader(){}
 
@@ -236,6 +240,12 @@ namespace dbaxml
            {
             delete this;
            }
+        IMPL_STATIC_LINK_NOINSTANCE( FastLoader, RunHdl, FastLoader*, pLoader )
+        {
+            pLoader->run();
+            delete pLoader;
+            return 0;
+        }
 
         class DatasourceURLListener : public ::cppu::WeakImplHelper1< 
beans::XPropertyChangeListener >
         {
@@ -260,7 +270,7 @@ namespace dbaxml
                 } // if ( m_aTypeCollection.needsJVM(sURL) )
                 else if ( sURL.matchIgnoreAsciiCaseAsciiL("sdbc:calc:",10,0) )
                 {
-                    pCreatorThread = new 
FastLoader(m_xFactory,FastLoader::E_CALC);
+                    Application::PostUserEvent( STATIC_LINK( NULL, FastLoader, 
RunHdl ), new FastLoader(m_xFactory,FastLoader::E_CALC) );
                 }
                 if ( pCreatorThread )
                 {
diff --git a/main/reportdesign/source/core/api/ReportDefinition.cxx 
b/main/reportdesign/source/core/api/ReportDefinition.cxx
index 8f40f39364..442d5113b4 100644
--- a/main/reportdesign/source/core/api/ReportDefinition.cxx
+++ b/main/reportdesign/source/core/api/ReportDefinition.cxx
@@ -104,7 +104,6 @@
 #include <dbaccess/dbaundomanager.hxx>
 #include <editeng/paperinf.hxx>
 #include <framework/titlehelper.hxx>
-#include <osl/thread.hxx>
 #include <svl/itempool.hxx>
 #include <svl/undo.hxx>
 #include <svx/svdlayer.hxx>
@@ -504,7 +503,9 @@ uno::Sequence< uno::Any > SAL_CALL 
OStyle::getPropertyDefaults( const uno::Seque
 }
 namespace
 {
-    class FactoryLoader : public ::osl::Thread
+    // Runs as a main-thread user event: as a detached thread it could outlive 
DeInitVCL
+    // and use the already deleted SolarMutex if the office terminated right 
after the first report.
+    class FactoryLoader
        {
         ::rtl::OUString                          m_sMimeType;
                uno::Reference< uno::XComponentContext > m_xContext;
@@ -514,15 +515,20 @@ namespace
             ,m_xContext(_xContext)
                {}
 
-       protected:
-        virtual ~FactoryLoader(){}
+               DECL_STATIC_LINK( FactoryLoader, LoadHdl, FactoryLoader* );
 
-               /// Working method which should be overridden.
-               virtual void SAL_CALL run();
-               virtual void SAL_CALL onTerminated();
+       private:
+               void load();
        };
 
-       void SAL_CALL FactoryLoader::run()
+       IMPL_STATIC_LINK_NOINSTANCE( FactoryLoader, LoadHdl, FactoryLoader*, 
pLoader )
+       {
+               pLoader->load();
+               delete pLoader;
+               return 0;
+       }
+
+       void FactoryLoader::load()
        {
                try
                {
@@ -565,10 +571,6 @@ namespace
             DBG_UNHANDLED_EXCEPTION();
                }
        }
-       void SAL_CALL FactoryLoader::onTerminated()
-       {
-        delete this;
-       }
 }
 // 
-----------------------------------------------------------------------------
 struct OReportDefinitionImpl
@@ -763,10 +765,8 @@ void OReportDefinition::init()
             const ::rtl::OUString* pEnd  = pIter + aMimeTypes.getLength();
             for ( ; pIter != pEnd; ++pIter )
             {
-                FactoryLoader* pCreatorThread = new 
FactoryLoader(*pIter,m_aProps->m_xContext);
-                   pCreatorThread->createSuspended();
-                pCreatorThread->setPriority(osl_Thread_PriorityBelowNormal);
-                pCreatorThread->resume();
+                FactoryLoader* pLoader = new 
FactoryLoader(*pIter,m_aProps->m_xContext);
+                Application::PostUserEvent( STATIC_LINK( NULL, FactoryLoader, 
LoadHdl ), pLoader );
             }
         }
 

Reply via email to