framework/source/uielement/recentfilesmenucontroller.cxx | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-)
New commits: commit 0a083eb3c644447ea2cb9664cae0ea40ade52aa1 Author: Caolán McNamara <[email protected]> AuthorDate: Mon Aug 26 20:18:03 2024 +0100 Commit: Michael Stahl <[email protected]> CommitDate: Tue Aug 27 10:38:23 2024 +0200 cid#1608206 Double lock Change-Id: I162e10b672277c77a7e0591b532d9197a79fc6d1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/172408 Tested-by: Jenkins Reviewed-by: Michael Stahl <[email protected]> diff --git a/framework/source/uielement/recentfilesmenucontroller.cxx b/framework/source/uielement/recentfilesmenucontroller.cxx index cae2900576f0..31b65b66a6c6 100644 --- a/framework/source/uielement/recentfilesmenucontroller.cxx +++ b/framework/source/uielement/recentfilesmenucontroller.cxx @@ -98,6 +98,7 @@ private: virtual void impl_setPopupMenu() override; void fillPopupMenu( css::uno::Reference< css::awt::XPopupMenu > const & rPopupMenu ); void executeEntry( sal_Int32 nIndex ); + void executeEntryImpl(std::unique_lock<std::mutex>& rGuard, sal_Int32 nIndex); std::vector<std::pair<OUString, bool>> m_aRecentFilesItems; bool m_bDisabled : 1; @@ -323,7 +324,7 @@ void RecentFilesMenuController::fillPopupMenu( Reference< css::awt::XPopupMenu > } } -void RecentFilesMenuController::executeEntry( sal_Int32 nIndex ) +void RecentFilesMenuController::executeEntryImpl(std::unique_lock<std::mutex>& rGuard, sal_Int32 nIndex) { if (( nIndex < 0 ) || ( nIndex >= sal::static_int_cast<sal_Int32>( m_aRecentFilesItems.size() ))) @@ -343,7 +344,13 @@ void RecentFilesMenuController::executeEntry( sal_Int32 nIndex ) aArgsList.realloc(aArgsList.size()+1); aArgsList.getArray()[aArgsList.size()-1] = comphelper::makePropertyValue(u"ReadOnly"_ustr, true); } - dispatchCommand(m_aRecentFilesItems[nIndex].first, aArgsList, u"_default"_ustr); + dispatchCommandImpl(rGuard, m_aRecentFilesItems[nIndex].first, aArgsList, u"_default"_ustr); +} + +void RecentFilesMenuController::executeEntry( sal_Int32 nIndex ) +{ + std::unique_lock aLock(m_aMutex); + executeEntryImpl(aLock, nIndex); } // XEventListener @@ -463,7 +470,7 @@ void SAL_CALL RecentFilesMenuController::dispatch( aEntryArg = aURL.Complete.subView( nEntryPos, nAddArgs-nEntryPos ); sal_Int32 nEntry = o3tl::toInt32(aEntryArg); - executeEntry( nEntry ); + executeEntryImpl(aLock, nEntry); } }
