framework/source/accelerators/acceleratorcache.cxx | 11 ------ framework/source/jobs/jobdata.cxx | 18 --------- framework/source/jobs/jobdispatch.cxx | 22 ------------ framework/source/jobs/jobexecutor.cxx | 38 +++++++-------------- 4 files changed, 13 insertions(+), 76 deletions(-)
New commits: commit 46becac127859a742e1f702bcde718304efcde69 Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Fri Jan 27 15:37:20 2023 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Fri Jan 27 16:04:03 2023 +0000 AcceleratorCache does not need to lock the SolarMutex it is only used by the *AccelerationConfiguration classes, and they lock the SolarMutex around all accesses to this data. Change-Id: I07de415bae9e0aff679f693022b9181971f19bd2 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146254 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/framework/source/accelerators/acceleratorcache.cxx b/framework/source/accelerators/acceleratorcache.cxx index 98596a895036..342b9701f99d 100644 --- a/framework/source/accelerators/acceleratorcache.cxx +++ b/framework/source/accelerators/acceleratorcache.cxx @@ -27,19 +27,16 @@ namespace framework { bool AcceleratorCache::hasKey(const css::awt::KeyEvent& aKey) const { - SolarMutexGuard g; return (m_lKey2Commands.find(aKey) != m_lKey2Commands.end()); } bool AcceleratorCache::hasCommand(const OUString& sCommand) const { - SolarMutexGuard g; return (m_lCommand2Keys.find(sCommand) != m_lCommand2Keys.end()); } AcceleratorCache::TKeyList AcceleratorCache::getAllKeys() const { - SolarMutexGuard g; TKeyList lKeys; lKeys.reserve(m_lKey2Commands.size()); @@ -53,8 +50,6 @@ AcceleratorCache::TKeyList AcceleratorCache::getAllKeys() const void AcceleratorCache::setKeyCommandPair(const css::awt::KeyEvent& aKey, const OUString& sCommand) { - SolarMutexGuard g; - // register command for the specified key m_lKey2Commands[aKey] = sCommand; @@ -65,7 +60,6 @@ void AcceleratorCache::setKeyCommandPair(const css::awt::KeyEvent& aKey, const O AcceleratorCache::TKeyList AcceleratorCache::getKeysByCommand(const OUString& sCommand) const { - SolarMutexGuard g; TCommand2Keys::const_iterator pCommand = m_lCommand2Keys.find(sCommand); if (pCommand == m_lCommand2Keys.end()) throw css::container::NoSuchElementException(); @@ -74,7 +68,6 @@ AcceleratorCache::TKeyList AcceleratorCache::getKeysByCommand(const OUString& sC OUString AcceleratorCache::getCommandByKey(const css::awt::KeyEvent& aKey) const { - SolarMutexGuard g; TKey2Commands::const_iterator pKey = m_lKey2Commands.find(aKey); if (pKey == m_lKey2Commands.end()) throw css::container::NoSuchElementException(); @@ -83,8 +76,6 @@ OUString AcceleratorCache::getCommandByKey(const css::awt::KeyEvent& aKey) const void AcceleratorCache::removeKey(const css::awt::KeyEvent& aKey) { - SolarMutexGuard g; - // check if key exists TKey2Commands::const_iterator pKey = m_lKey2Commands.find(aKey); if (pKey == m_lKey2Commands.end()) @@ -105,8 +96,6 @@ void AcceleratorCache::removeKey(const css::awt::KeyEvent& aKey) void AcceleratorCache::removeCommand(const OUString& sCommand) { - SolarMutexGuard g; - const TKeyList& lKeys = getKeysByCommand(sCommand); for (auto const& lKey : lKeys) { commit 943b58c9577c4e43c04fb2df81203af3fd0da433 Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Fri Jan 27 15:12:35 2023 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Fri Jan 27 16:03:51 2023 +0000 Remove SolarMutex usage from framework::JobData the data in question is only touched from one thread, so it does not need any locking. This seems have been since this class was first introduced. Change-Id: Ife9f9ea015e2ae263e699a38d504a49aaf21c803 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146253 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/framework/source/jobs/jobdata.cxx b/framework/source/jobs/jobdata.cxx index ded3570e8dbf..0ca06fcaca8a 100644 --- a/framework/source/jobs/jobdata.cxx +++ b/framework/source/jobs/jobdata.cxx @@ -77,7 +77,6 @@ JobData::JobData( const JobData& rCopy ) */ JobData& JobData::operator=( const JobData& rCopy ) { - SolarMutexGuard g; // Please don't copy the uno service manager reference. // That can change the uno context, which isn't a good idea! m_eMode = rCopy.m_eMode; @@ -111,7 +110,6 @@ JobData::~JobData() */ void JobData::setAlias( const OUString& sAlias ) { - SolarMutexGuard g; // delete all old information! Otherwise we mix it with the new one ... impl_reset(); @@ -177,7 +175,6 @@ void JobData::setAlias( const OUString& sAlias ) */ void JobData::setService( const OUString& sService ) { - SolarMutexGuard g; // delete all old information! Otherwise we mix it with the new one ... impl_reset(); // take over the new information @@ -209,7 +206,6 @@ void JobData::setEvent( const OUString& sEvent , // share code to read all job properties! setAlias(sAlias); - SolarMutexGuard g; // take over the new information - which differ against set one of method setAlias()! m_sEvent = sEvent; m_eMode = E_EVENT; @@ -228,8 +224,6 @@ void JobData::setEvent( const OUString& sEvent , */ void JobData::setJobConfig( std::vector< css::beans::NamedValue >&& lArguments ) { - SolarMutexGuard g; - // update member m_lArguments = std::move(lArguments); @@ -276,7 +270,6 @@ void JobData::setJobConfig( std::vector< css::beans::NamedValue >&& lArguments ) */ void JobData::setEnvironment( EEnvironment eEnvironment ) { - SolarMutexGuard g; m_eEnvironment = eEnvironment; } @@ -287,20 +280,17 @@ void JobData::setEnvironment( EEnvironment eEnvironment ) */ JobData::EMode JobData::getMode() const { - SolarMutexGuard g; return m_eMode; } JobData::EEnvironment JobData::getEnvironment() const { - SolarMutexGuard g; return m_eEnvironment; } OUString JobData::getEnvironmentDescriptor() const { OUString sDescriptor; - SolarMutexGuard g; switch(m_eEnvironment) { case E_EXECUTION : @@ -322,25 +312,21 @@ OUString JobData::getEnvironmentDescriptor() const OUString JobData::getService() const { - SolarMutexGuard g; return m_sService; } OUString JobData::getEvent() const { - SolarMutexGuard g; return m_sEvent; } std::vector< css::beans::NamedValue > JobData::getJobConfig() const { - SolarMutexGuard g; return m_lArguments; } css::uno::Sequence< css::beans::NamedValue > JobData::getConfig() const { - SolarMutexGuard g; css::uno::Sequence< css::beans::NamedValue > lConfig; if (m_eMode==E_ALIAS) { @@ -364,7 +350,6 @@ css::uno::Sequence< css::beans::NamedValue > JobData::getConfig() const */ bool JobData::hasConfig() const { - SolarMutexGuard g; return (m_eMode==E_ALIAS || m_eMode==E_EVENT); } @@ -380,8 +365,6 @@ bool JobData::hasConfig() const */ void JobData::disableJob() { - SolarMutexGuard g; - // No configuration - not used from EXECUTOR and not triggered from an event => no chance! if (m_eMode!=E_EVENT) return; @@ -548,7 +531,6 @@ std::vector< OUString > JobData::getEnabledJobsForEvent( const css::uno::Referen */ void JobData::impl_reset() { - SolarMutexGuard g; m_eMode = E_UNKNOWN_MODE; m_eEnvironment = E_UNKNOWN_ENVIRONMENT; m_sAlias.clear(); diff --git a/framework/source/jobs/jobdispatch.cxx b/framework/source/jobs/jobdispatch.cxx index d1e227b9a55a..2352919dea09 100644 --- a/framework/source/jobs/jobdispatch.cxx +++ b/framework/source/jobs/jobdispatch.cxx @@ -301,11 +301,7 @@ void JobDispatch::impl_dispatchEvent( /*IN*/ const OUString& // get list of all enabled jobs // The called static helper methods read it from the configuration and // filter disabled jobs using it's time stamp values. - /* SAFE { */ - SolarMutexResettableGuard aReadLock; std::vector< OUString > lJobs = JobData::getEnabledJobsForEvent(m_xContext, sEvent); - aReadLock.clear(); - /* } SAFE */ css::uno::Reference< css::frame::XDispatchResultListener > xThis( static_cast< ::cppu::OWeakObject* >(this), css::uno::UNO_QUERY ); @@ -317,9 +313,6 @@ void JobDispatch::impl_dispatchEvent( /*IN*/ const OUString& int nExecutedJobs=0; for (const OUString & lJob : lJobs) { - /* SAFE { */ - aReadLock.reset(); - JobData aCfg(m_xContext); aCfg.setEvent(sEvent, lJob); aCfg.setEnvironment(JobData::E_DISPATCH); @@ -328,9 +321,6 @@ void JobDispatch::impl_dispatchEvent( /*IN*/ const OUString& rtl::Reference<Job> pJob = new Job(m_xContext, m_xFrame); pJob->setJobData(aCfg); - aReadLock.clear(); - /* } SAFE */ - if (!bIsEnabled) continue; @@ -374,9 +364,6 @@ void JobDispatch::impl_dispatchService( /*IN*/ const OUString& /*IN*/ const css::uno::Sequence< css::beans::PropertyValue >& lArgs , /*IN*/ const css::uno::Reference< css::frame::XDispatchResultListener >& xListener ) { - /* SAFE { */ - SolarMutexClearableGuard aReadLock; - JobData aCfg(m_xContext); aCfg.setService(sService); aCfg.setEnvironment(JobData::E_DISPATCH); @@ -389,9 +376,6 @@ void JobDispatch::impl_dispatchService( /*IN*/ const OUString& rtl::Reference<Job> pJob = new Job(m_xContext, m_xFrame); pJob->setJobData(aCfg); - aReadLock.clear(); - /* } SAFE */ - css::uno::Reference< css::frame::XDispatchResultListener > xThis( static_cast< ::cppu::OWeakObject* >(this), css::uno::UNO_QUERY ); // Special mode for listener. @@ -423,9 +407,6 @@ void JobDispatch::impl_dispatchAlias( /*IN*/ const OUString& /*IN*/ const css::uno::Sequence< css::beans::PropertyValue >& lArgs , /*IN*/ const css::uno::Reference< css::frame::XDispatchResultListener >& xListener ) { - /* SAFE { */ - SolarMutexClearableGuard aReadLock; - JobData aCfg(m_xContext); aCfg.setAlias(sAlias); aCfg.setEnvironment(JobData::E_DISPATCH); @@ -433,9 +414,6 @@ void JobDispatch::impl_dispatchAlias( /*IN*/ const OUString& rtl::Reference<Job> pJob = new Job(m_xContext, m_xFrame); pJob->setJobData(aCfg); - aReadLock.clear(); - /* } SAFE */ - css::uno::Reference< css::frame::XDispatchResultListener > xThis( static_cast< ::cppu::OWeakObject* >(this), css::uno::UNO_QUERY ); // Special mode for listener. diff --git a/framework/source/jobs/jobexecutor.cxx b/framework/source/jobs/jobexecutor.cxx index 65c7dc25ded4..f5776fdf283d 100644 --- a/framework/source/jobs/jobexecutor.cxx +++ b/framework/source/jobs/jobexecutor.cxx @@ -195,8 +195,6 @@ void SAL_CALL JobExecutor::trigger( const OUString& sEvent ) { SAL_INFO( "fwk", "JobExecutor::trigger()"); - std::vector< OUString > lJobs; - /* SAFE */ { osl::MutexGuard g(rBHelper.rMutex); @@ -206,34 +204,28 @@ void SAL_CALL JobExecutor::trigger( const OUString& sEvent ) if (std::find(m_lEvents.begin(), m_lEvents.end(), sEvent) == m_lEvents.end()) return; + } /* SAFE */ + // get list of all enabled jobs // The called static helper methods read it from the configuration and // filter disabled jobs using it's time stamp values. - lJobs = JobData::getEnabledJobsForEvent(m_xContext, sEvent); - } /* SAFE */ + std::vector< OUString > lJobs = JobData::getEnabledJobsForEvent(m_xContext, sEvent); // step over all enabled jobs and execute it size_t c = lJobs.size(); for (size_t j=0; j<c; ++j) { - rtl::Reference<Job> pJob; - - /* SAFE */ - { - SolarMutexGuard g2; - - JobData aCfg(m_xContext); - aCfg.setEvent(sEvent, lJobs[j]); - aCfg.setEnvironment(JobData::E_EXECUTION); + JobData aCfg(m_xContext); + aCfg.setEvent(sEvent, lJobs[j]); + aCfg.setEnvironment(JobData::E_EXECUTION); - /*Attention! - Jobs implements interfaces and dies by ref count! - And freeing of such uno object is done by uno itself. - So we have to use dynamic memory everytimes. - */ - pJob = new Job(m_xContext, css::uno::Reference< css::frame::XFrame >()); - pJob->setJobData(aCfg); - } /* SAFE */ + /*Attention! + Jobs implements interfaces and dies by ref count! + And freeing of such uno object is done by uno itself. + So we have to use dynamic memory everytimes. + */ + rtl::Reference<Job> pJob = new Job(m_xContext, css::uno::Reference< css::frame::XFrame >()); + pJob->setJobData(aCfg); pJob->execute(css::uno::Sequence< css::beans::NamedValue >()); } @@ -293,9 +285,6 @@ void SAL_CALL JobExecutor::notifyEvent( const css::document::EventObject& aEvent { rtl::Reference<Job> pJob; - /* SAFE */ { - SolarMutexGuard g2; - const JobData::TJob2DocEventBinding& rBinding = lJob; JobData aCfg(m_xContext); @@ -313,7 +302,6 @@ void SAL_CALL JobExecutor::notifyEvent( const css::document::EventObject& aEvent css::uno::Reference< css::frame::XModel > xModel(aEvent.Source, css::uno::UNO_QUERY); pJob = new Job(m_xContext, xModel); pJob->setJobData(aCfg); - } /* SAFE */ pJob->execute(css::uno::Sequence< css::beans::NamedValue >()); }