summaryrefslogtreecommitdiff
path: root/framework
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2021-07-30 10:10:55 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2021-07-30 14:07:43 +0200
commit7b5922eb666e5f153060468b271d99510adb422e (patch)
tree72c5d22944a7250b2ec69ef7968bdcac0fe74439 /framework
parent74f4a1796f94477d459c71d0a0aaa8f4a430e208 (diff)
osl::Mutex->std::mutex in DispatchHelper
Change-Id: I6443f604f7f5cacc4b3d67bb6dab07706c82a9a7 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/119700 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'framework')
-rw-r--r--framework/source/services/dispatchhelper.cxx28
1 files changed, 17 insertions, 11 deletions
diff --git a/framework/source/services/dispatchhelper.cxx b/framework/source/services/dispatchhelper.cxx
index 380eab11ec67..cfa4a8a2bbe1 100644
--- a/framework/source/services/dispatchhelper.cxx
+++ b/framework/source/services/dispatchhelper.cxx
@@ -53,6 +53,7 @@ css::uno::Sequence<OUString> SAL_CALL DispatchHelper::getSupportedServiceNames()
*/
DispatchHelper::DispatchHelper(const css::uno::Reference<css::uno::XComponentContext>& xContext)
: m_xContext(xContext)
+ , m_aBlockFlag(false)
{
}
@@ -91,11 +92,12 @@ css::uno::Any SAL_CALL DispatchHelper::executeDispatch(
}
// parse given URL
+ css::uno::Reference<css::util::XURLTransformer> xParser;
/* SAFE { */
- osl::ClearableMutexGuard aReadLock(m_mutex);
- css::uno::Reference<css::util::XURLTransformer> xParser
- = css::util::URLTransformer::create(m_xContext);
- aReadLock.clear();
+ {
+ std::lock_guard aReadLock(m_mutex);
+ xParser = css::util::URLTransformer::create(m_xContext);
+ }
/* } SAFE */
css::util::URL aURL;
@@ -148,16 +150,18 @@ DispatchHelper::executeDispatch(const css::uno::Reference<css::frame::XDispatch>
css::uno::UNO_QUERY);
/* SAFE { */
{
- osl::MutexGuard aWriteLock(m_mutex);
+ std::lock_guard aWriteLock(m_mutex);
m_xBroadcaster = xNotifyDispatch;
- m_aBlock.reset();
+ m_aBlockFlag = false;
}
/* } SAFE */
// dispatch it and wait for a notification
// TODO/MBA: waiting in main thread?!
xNotifyDispatch->dispatchWithNotification(aURL, aArguments, xListener);
- m_aBlock.wait(); // wait for result
+
+ std::unique_lock aWriteLock(m_mutex);
+ m_aBlock.wait(aWriteLock, [this] { return m_aBlockFlag; }); // wait for result
}
else
{
@@ -180,9 +184,10 @@ DispatchHelper::executeDispatch(const css::uno::Reference<css::frame::XDispatch>
*/
void SAL_CALL DispatchHelper::dispatchFinished(const css::frame::DispatchResultEvent& aResult)
{
- osl::MutexGuard g(m_mutex);
+ std::lock_guard g(m_mutex);
m_aResult <<= aResult;
- m_aBlock.set();
+ m_aBlockFlag = true;
+ m_aBlock.notify_one();
m_xBroadcaster.clear();
}
@@ -193,9 +198,10 @@ void SAL_CALL DispatchHelper::dispatchFinished(const css::frame::DispatchResultE
*/
void SAL_CALL DispatchHelper::disposing(const css::lang::EventObject&)
{
- osl::MutexGuard g(m_mutex);
+ std::lock_guard g(m_mutex);
m_aResult.clear();
- m_aBlock.set();
+ m_aBlockFlag = true;
+ m_aBlock.notify_one();
m_xBroadcaster.clear();
}
}