summaryrefslogtreecommitdiff
path: root/UnoControls
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2021-07-22 13:09:20 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2021-07-22 18:50:49 +0200
commit1296ded169adaa93d943eeb0273bf16835f7eb35 (patch)
tree78fd98fde74e24537f939e081b2f3c25b88e13fe /UnoControls
parent0f15f1ec7c7b9ed7abf4a40b9b9c2f3876ce3e5f (diff)
fix the mutex locking in impl_searchTopic
you cannot take a pointer to something inside a guard and then use that data outside the guard. So remove the broken locking here, and make sure the call sites hold the lock. Change-Id: I37cc363ff937243d7965844e8bcda0018085c656 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/119370 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'UnoControls')
-rw-r--r--UnoControls/source/controls/progressmonitor.cxx36
1 files changed, 15 insertions, 21 deletions
diff --git a/UnoControls/source/controls/progressmonitor.cxx b/UnoControls/source/controls/progressmonitor.cxx
index e8dca471b816..fa7ab1aa7098 100644
--- a/UnoControls/source/controls/progressmonitor.cxx
+++ b/UnoControls/source/controls/progressmonitor.cxx
@@ -192,6 +192,9 @@ void SAL_CALL ProgressMonitor::addText(
sal_Bool bbeforeProgress
)
{
+ // Ready for multithreading
+ MutexGuard aGuard ( m_aMutex );
+
// Safe impossible cases
// Check valid call of this method.
DBG_ASSERT ( impl_debug_checkParameter ( rTopic, rText ), "ProgressMonitor::addText()\nCall without valid parameters!\n");
@@ -210,9 +213,6 @@ void SAL_CALL ProgressMonitor::addText(
aTextItem.sTopic = rTopic;
aTextItem.sText = rText;
- // Ready for multithreading
- MutexGuard aGuard ( m_aMutex );
-
// ... and insert it in right list.
if ( bbeforeProgress )
{
@@ -235,15 +235,15 @@ void SAL_CALL ProgressMonitor::removeText ( const OUString& rTopic, sal_Bool bbe
// Check valid call of this method.
DBG_ASSERT ( impl_debug_checkParameter ( rTopic ), "ProgressMonitor::removeText()\nCall without valid parameters!" );
+ // Ready for multithreading
+ MutexGuard aGuard ( m_aMutex );
+
// Search the topic ...
IMPL_TextlistItem* pSearchItem = impl_searchTopic ( rTopic, bbeforeProgress );
if ( pSearchItem == nullptr )
return;
- // Ready for multithreading
- MutexGuard aGuard ( m_aMutex );
-
// ... delete item from right list ...
if ( bbeforeProgress )
{
@@ -278,14 +278,14 @@ void SAL_CALL ProgressMonitor::updateText (
// Check valid call of this method.
DBG_ASSERT ( impl_debug_checkParameter ( rTopic, rText ), "ProgressMonitor::updateText()\nCall without valid parameters!\n" );
+ // Ready for multithreading
+ MutexGuard aGuard ( m_aMutex );
+
// Search topic ...
IMPL_TextlistItem* pSearchItem = impl_searchTopic ( rTopic, bbeforeProgress );
if ( pSearchItem != nullptr )
{
- // Ready for multithreading
- MutexGuard aGuard ( m_aMutex );
-
// ... update text ...
pSearchItem->sText = rText;
@@ -791,20 +791,14 @@ IMPL_TextlistItem* ProgressMonitor::impl_searchTopic ( std::u16string_view rTopi
// Get right textlist for following operations.
::std::vector< IMPL_TextlistItem >* pTextList;
- // Ready for multithreading
+ if (bbeforeProgress)
{
- MutexGuard aGuard(m_aMutex);
-
- if (bbeforeProgress)
- {
- pTextList = &maTextlist_Top;
- }
- else
- {
- pTextList = &maTextlist_Bottom;
- }
+ pTextList = &maTextlist_Top;
+ }
+ else
+ {
+ pTextList = &maTextlist_Bottom;
}
- // Switch off guard.
// Search the topic in textlist.
size_t nPosition = 0;