[Libreoffice-commits] core.git: desktop/source include/vcl vcl/headless vcl/inc vcl/source

Henry Castro hcastro at collabora.com
Wed Feb 28 21:48:19 UTC 2018


 desktop/source/lib/init.cxx  |    2 ++
 include/vcl/svapp.hxx        |    3 +++
 vcl/headless/svpinst.cxx     |    6 ++++++
 vcl/inc/headless/svpinst.hxx |    1 +
 vcl/inc/salinst.hxx          |    2 ++
 vcl/source/app/svapp.cxx     |    7 +++++++
 6 files changed, 21 insertions(+)

New commits:
commit e215310d6b531b8af39c86639ef88495470681bc
Author: Henry Castro <hcastro at collabora.com>
Date:   Tue Feb 27 19:55:39 2018 -0400

    lok: update main thread
    
    In the pre-initialization phase of the tiled rendering case
    the SvpSalInstance is created in a different process and when
    a new process is created (fork), the main thread identifier
    does not match so it is required to update it.
    
    Change-Id: I189e53f0b46c60f34a8016222079c9b1e2b3fef8
    Reviewed-on: https://gerrit.libreoffice.org/50477
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Henry Castro <hcastro at collabora.com>

diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 143ec46fdc63..d0978b449937 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -3582,6 +3582,8 @@ static void lo_startmain(void*)
     if (comphelper::SolarMutex::get())
         Application::GetSolarMutex().tryToAcquire();
 
+    Application::UpdateMainThread();
+
     soffice_main();
 
     Application::ReleaseSolarMutex();
diff --git a/include/vcl/svapp.hxx b/include/vcl/svapp.hxx
index 29b8f2c258b3..d9daba3154a8 100644
--- a/include/vcl/svapp.hxx
+++ b/include/vcl/svapp.hxx
@@ -1352,6 +1352,9 @@ public:
     static void                 ShowNativeErrorBox(const OUString& sTitle  ,
                                                    const OUString& sMessage);
 
+    /** Update main thread identifier */
+    static void                 UpdateMainThread();
+
     /** Do we have a native / system file selector available?
 
      @returns True if native file selector is available, false otherwise.
diff --git a/vcl/headless/svpinst.cxx b/vcl/headless/svpinst.cxx
index 61fc93883f6a..412e86c55351 100644
--- a/vcl/headless/svpinst.cxx
+++ b/vcl/headless/svpinst.cxx
@@ -385,6 +385,12 @@ bool SvpSalInstance::IsMainThread() const
     return osl::Thread::getCurrentIdentifier() == m_MainThread;
 }
 
+void SvpSalInstance::updateMainThread()
+{
+    if (!IsMainThread())
+        m_MainThread = osl::Thread::getCurrentIdentifier();
+}
+
 bool SvpSalInstance::DoYield(bool bWait, bool bHandleAllCurrentEvents)
 {
 #ifndef NDEBUG
diff --git a/vcl/inc/headless/svpinst.hxx b/vcl/inc/headless/svpinst.hxx
index 6027b2b4d683..1dd577b78fb1 100644
--- a/vcl/inc/headless/svpinst.hxx
+++ b/vcl/inc/headless/svpinst.hxx
@@ -171,6 +171,7 @@ public:
     virtual bool            DoYield(bool bWait, bool bHandleAllCurrentEvents) override;
     virtual bool            AnyInput( VclInputFlags nType ) override;
     virtual bool            IsMainThread() const override;
+    virtual void            updateMainThread() override;
 
     // may return NULL to disable session management
     virtual SalSession*     CreateSalSession() override;
diff --git a/vcl/inc/salinst.hxx b/vcl/inc/salinst.hxx
index 600f8ddfb8b3..8b7a77f34543 100644
--- a/vcl/inc/salinst.hxx
+++ b/vcl/inc/salinst.hxx
@@ -186,6 +186,8 @@ public:
     virtual void            jobStartedPrinterUpdate() {}
     virtual void            jobEndedPrinterUpdate() {}
 
+    virtual void            updateMainThread() {}
+
     /// get information about underlying versions
     virtual OUString        getOSVersion() { return OUString("-"); }
 
diff --git a/vcl/source/app/svapp.cxx b/vcl/source/app/svapp.cxx
index 3276eed372d5..4543b6835fb7 100644
--- a/vcl/source/app/svapp.cxx
+++ b/vcl/source/app/svapp.cxx
@@ -1313,6 +1313,13 @@ void Application::SetHelp( Help* pHelp )
     ImplGetSVData()->maAppData.mpHelp = pHelp;
 }
 
+void Application::UpdateMainThread()
+{
+    ImplSVData* pSVData = ImplGetSVData();
+    if (pSVData && pSVData->mpDefInst)
+        pSVData->mpDefInst->updateMainThread();
+}
+
 Help* Application::GetHelp()
 {
     return ImplGetSVData()->maAppData.mpHelp;


More information about the Libreoffice-commits mailing list