diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2018-06-04 16:28:22 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2018-06-05 17:13:39 +0200 |
commit | 400137b1d36e4296e4e297a4c570933e6572b38c (patch) | |
tree | b422f4b99f372dfa6e9c7f3dac7daa9f381a4b6b | |
parent | 777fe663fdcccc8ae2233cfb8287e888a9e5bf87 (diff) |
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@libreoffice.org>
Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
-rw-r--r-- | cui/source/options/personalization.cxx | 8 | ||||
-rw-r--r-- | cui/source/options/personalization.hxx | 4 |
2 files changed, 8 insertions, 4 deletions
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; |