[Libreoffice-commits] core.git: Branch 'libreoffice-6-1' - cui/source

Miklos Vajna vmiklos at collabora.co.uk
Tue Jun 5 15:14:00 UTC 2018


 cui/source/options/personalization.cxx |    8 +++++---
 cui/source/options/personalization.hxx |    4 +++-
 2 files changed, 8 insertions(+), 4 deletions(-)

New commits:
commit 400137b1d36e4296e4e297a4c570933e6572b38c
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Mon Jun 4 16:28:22 2018 +0200

    tdf#117866 cui: avoid deadlock in personalization dialog
    
    The deadlock happened as the main thread wanted to join
    SearchAndParseThread (while owning the solar mutex), but
    SearchAndParseThread wanted to take the solar mutex to import a graphic.
    
    Fix the deadlock by checking for the termination flag earlier, so we
    don't take any new mutexes if termination was requested already.
    
    (cherry picked from commit 766c85a4f67f5d50645340e31cebd5956998c6fc)
    
    Related: tdf#117866 cui: use std::atomic for thread termination flag
    
    (cherry picked from commit f4ac7b5a084a7cf483bb89a2fa411f9df70df4d0)
    
    Change-Id: Idddaadadc693610d9f31a14300b22aff8d452756
    Reviewed-on: https://gerrit.libreoffice.org/55334
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>

diff --git a/cui/source/options/personalization.cxx b/cui/source/options/personalization.cxx
index d05775e93a53..7b4cf6807170 100644
--- a/cui/source/options/personalization.cxx
+++ b/cui/source/options/personalization.cxx
@@ -778,14 +778,16 @@ void SearchAndParseThread::execute()
                 continue;
             }
             INetURLObject aURLObj( sPreviewFile );
+
+            // Stop the thread if requested -- before taking the solar mutex.
+            if( !m_bExecute )
+                return;
+
             // for VCL to be able to create bitmaps / do visual changes in the thread
             SolarMutexGuard aGuard;
             aFilter.ImportGraphic( aGraphic, aURLObj );
             Bitmap aBmp = aGraphic.GetBitmap();
 
-            if( !m_bExecute )
-                return;
-
             m_pPersonaDialog->SetImages( Image( aBmp ), nIndex++ );
             m_pPersonaDialog->setOptimalLayoutSize();
             m_pPersonaDialog->AddPersonaSetting( aPersonaSetting );
diff --git a/cui/source/options/personalization.hxx b/cui/source/options/personalization.hxx
index 1f1e1f1e77ca..aae43240ea80 100644
--- a/cui/source/options/personalization.hxx
+++ b/cui/source/options/personalization.hxx
@@ -16,6 +16,7 @@
 #include <vcl/prgsbar.hxx>
 #include <vector>
 #include <array>
+#include <atomic>
 
 #define CATEGORYCOUNT 6    // Number of persona categories
 
@@ -119,7 +120,8 @@ private:
 
     VclPtr<SelectPersonaDialog> m_pPersonaDialog;
     OUString m_aURL;
-    bool m_bExecute, m_bDirectURL;
+    std::atomic<bool> m_bExecute;
+    bool m_bDirectURL;
 
     virtual ~SearchAndParseThread() override;
     virtual void execute() override;


More information about the Libreoffice-commits mailing list