[Libreoffice-commits] .: Branch 'libreoffice-3-5' - 2 commits - linguistic/source sw/source vcl/source

Michael Stahl mst at kemper.freedesktop.org
Tue Jan 17 13:21:43 PST 2012


 linguistic/source/gciterator.cxx |   61 +++++++++++++++++----------------------
 linguistic/source/gciterator.hxx |    5 ++-
 sw/source/ui/uiview/view1.cxx    |    4 ++
 vcl/source/app/svmain.cxx        |    4 ++
 4 files changed, 40 insertions(+), 34 deletions(-)

New commits:
commit 74255f5e0b89d60102e0b482ed894c64de57b42c
Author: Cédric Bosdonnat <cedric.bosdonnat.ooo at free.fr>
Date:   Fri Jan 13 16:04:09 2012 +0100

    fdo#40438: force calculating layout before Activate to avoid crashes and loops
    
    (cherry picked from commit d83488f9795740857830aaf005e06e30d4e7d70c)
    
    Signed-off-by: Michael Stahl <mstahl at redhat.com>

diff --git a/sw/source/ui/uiview/view1.cxx b/sw/source/ui/uiview/view1.cxx
index 23d80f9..79ec899 100644
--- a/sw/source/ui/uiview/view1.cxx
+++ b/sw/source/ui/uiview/view1.cxx
@@ -53,6 +53,10 @@ extern int bDocSzUpdated;
 
 void SwView::Activate(sal_Bool bMDIActivate)
 {
+    // fdo#40438 Update the layout to make sure everything is correct before showing the content
+    pWrtShell->StartAction();
+    pWrtShell->EndAction( sal_True );
+
     // aktuelle View anmelden an der DocShell
     // die View bleibt solange an der DocShell
     // aktiv bis Sie zerstoert wird oder durch Activate eine
commit 69ba498b4cfd2b25ddc1c84f83d376d11c321fce
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Fri Dec 16 16:06:42 2011 +0100

    Properly join spawned GrammarCheckingIterator thread.
    
    It was still running during shutdown of sw_complex's checkFlies test, causing
    problems.
    For this to work, Desktop::DeInit needs to be called with SolarMutex unlocked,
    which looks like the right way, anyway.  Hopefully it does not unearth another
    round of bugs...
    
    (cherry picked from commit c5cf78e1529970c04e1999e1f96f3e374ecd211e)
    
    Signed-off-by: Michael Stahl <mstahl at redhat.com>
    Signed-off-by: Stephan Bergmann <sbergman at redhat.com>

diff --git a/linguistic/source/gciterator.cxx b/linguistic/source/gciterator.cxx
index 9828052..91c407c 100644
--- a/linguistic/source/gciterator.cxx
+++ b/linguistic/source/gciterator.cxx
@@ -252,15 +252,31 @@ GrammarCheckingIterator::GrammarCheckingIterator( const uno::Reference< lang::XM
     m_aEventListeners( MyMutex::get() ),
     m_aNotifyListeners( MyMutex::get() )
 {
-    osl_createThread( workerfunc, this );
+    m_thread = osl_createThread( workerfunc, this );
 }
 
 
 GrammarCheckingIterator::~GrammarCheckingIterator()
 {
-    ::osl::Guard< ::osl::Mutex > aGuard( MyMutex::get() );
+    TerminateThread();
 }
 
+void GrammarCheckingIterator::TerminateThread()
+{
+    oslThread t;
+    {
+        ::osl::Guard< ::osl::Mutex > aGuard( MyMutex::get() );
+        t = m_thread;
+        m_thread = 0;
+        m_bEnd = sal_True;
+        m_aWakeUpThread.set();
+    }
+    if (t != 0)
+    {
+        osl_joinWithThread(t);
+        osl_destroyThread(t);
+    }
+}
 
 sal_Int32 GrammarCheckingIterator::NextDocId()
 {
@@ -489,19 +505,16 @@ void GrammarCheckingIterator::DequeueAndCheck()
     uno::Sequence< sal_Int32 >      aLangPortions;
     uno::Sequence< lang::Locale >   aLangPortionsLocale;
 
-    // ---- THREAD SAFE START ----
-    bool bEnd = false;
-    {
-        ::osl::Guard< ::osl::Mutex > aGuard( MyMutex::get() );
-        bEnd = m_bEnd;
-    }
-    // ---- THREAD SAFE END ----
-    while (!bEnd)
+    for (;;)
     {
         // ---- THREAD SAFE START ----
         bool bQueueEmpty = false;
         {
             ::osl::Guard< ::osl::Mutex > aGuard( MyMutex::get() );
+            if (m_bEnd)
+            {
+                break;
+            }
             bQueueEmpty = m_aFPEntriesQueue.empty();
         }
         // ---- THREAD SAFE END ----
@@ -605,6 +618,10 @@ void GrammarCheckingIterator::DequeueAndCheck()
             // ---- THREAD SAFE START ----
             {
                 ::osl::Guard< ::osl::Mutex > aGuard( MyMutex::get() );
+                if (m_bEnd)
+                {
+                    break;
+                }
                 // Check queue state again
                 if (m_aFPEntriesQueue.empty())
                     m_aWakeUpThread.reset();
@@ -618,17 +635,7 @@ void GrammarCheckingIterator::DequeueAndCheck()
             // safe implemented.
             m_aWakeUpThread.wait();
         }
-
-        // ---- THREAD SAFE START ----
-        {
-            ::osl::Guard< ::osl::Mutex > aGuard( MyMutex::get() );
-            bEnd = m_bEnd;
-        }
-        // ---- THREAD SAFE END ----
     }
-
-    //!! This one must be the very last statement to call in this function !!
-    m_aRequestEndThread.set();
 }
 
 
@@ -901,19 +908,7 @@ throw (uno::RuntimeException)
     lang::EventObject aEvt( (linguistic2::XProofreadingIterator *) this );
     m_aEventListeners.disposeAndClear( aEvt );
 
-    // now end the thread...
-    m_aRequestEndThread.reset();
-    // ---- THREAD SAFE START ----
-    {
-        ::osl::Guard< ::osl::Mutex > aGuard( MyMutex::get() );
-        m_bEnd = sal_True;
-    }
-    // ---- THREAD SAFE END ----
-    m_aWakeUpThread.set();
-    const TimeValue aTime = { 3, 0 };   // wait 3 seconds...
-    m_aRequestEndThread.wait( &aTime );
-    // if the call ends because of time-out we will end anyway...
-
+    TerminateThread();
 
     // ---- THREAD SAFE START ----
     {
diff --git a/linguistic/source/gciterator.hxx b/linguistic/source/gciterator.hxx
index aab04dd..8dda009 100644
--- a/linguistic/source/gciterator.hxx
+++ b/linguistic/source/gciterator.hxx
@@ -43,6 +43,7 @@
 #include <cppuhelper/weakref.hxx>
 #include <osl/mutex.hxx>
 #include <osl/conditn.hxx>
+#include <osl/thread.h>
 #include <rtl/instance.hxx>
 
 #include <map>
@@ -122,7 +123,7 @@ class GrammarCheckingIterator:
     sal_Int32       m_nDocIdCounter;
     sal_Int32       m_nLastEndOfSentencePos;
     osl::Condition  m_aWakeUpThread;
-    osl::Condition  m_aRequestEndThread;
+    oslThread       m_thread;
 
     //! beware of initilization order !
     struct MyMutex : public rtl::Static< osl::Mutex, MyMutex > {};
@@ -132,6 +133,8 @@ class GrammarCheckingIterator:
     ::com::sun::star::uno::Reference< ::com::sun::star::i18n::XBreakIterator > m_xBreakIterator;
     mutable ::com::sun::star::uno::Reference< ::com::sun::star::util::XChangesBatch >  m_xUpdateAccess;
 
+    void TerminateThread();
+
     sal_Int32 NextDocId();
     ::rtl::OUString GetOrCreateDocId( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent > &xComp );
 
diff --git a/vcl/source/app/svmain.cxx b/vcl/source/app/svmain.cxx
index 5ab01b9..cf98fb8 100644
--- a/vcl/source/app/svmain.cxx
+++ b/vcl/source/app/svmain.cxx
@@ -489,10 +489,14 @@ void DeInitVCL()
     pSVData->maAppData.mxMSF.clear();
 
     if( pSVData->mpApp )
+    {
+        sal_uLong nCount = Application::ReleaseSolarMutex();
         // call deinit to deinitialize application class
         // soffice/sfx implementation disposes the global service manager
         // Warning: After this call you can't call uno services
         pSVData->mpApp->DeInit();
+        Application::AcquireSolarMutex(nCount);
+    }
 
     if ( pSVData->maAppData.mpSettings )
     {


More information about the Libreoffice-commits mailing list