diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2019-04-07 11:48:47 +0300 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2019-04-07 17:53:04 +0200 |
commit | 5a824268dfdd48c00f656b767b48cd12ccbdaabb (patch) | |
tree | a25f4afd3ca49cff41fc44559aedea70c82e6c7e | |
parent | a6186a678cd9f67359da885606b3c3983f6bdc74 (diff) |
Don't use resettable/clearable guard where plain guard is enough
Also use scope where possible. This allows to limit guard scope at
language level; visualises the scope clearly; and helps avoiding
errors like fixed in commit 61e4437c857854b331fa01da6f39b2b3b58a800b.
Change-Id: Ifeca96e2df8e8a0897770d9546b2536806275f41
Reviewed-on: https://gerrit.libreoffice.org/70376
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
84 files changed, 1378 insertions, 1348 deletions
diff --git a/UnoControls/source/controls/progressmonitor.cxx b/UnoControls/source/controls/progressmonitor.cxx index 7e439beb5e60..23451ac5c2a9 100644 --- a/UnoControls/source/controls/progressmonitor.cxx +++ b/UnoControls/source/controls/progressmonitor.cxx @@ -799,19 +799,19 @@ IMPL_TextlistItem* ProgressMonitor::impl_searchTopic ( const OUString& rTopic, b ::std::vector< std::unique_ptr<IMPL_TextlistItem> >* pTextList; // Ready for multithreading - ClearableMutexGuard aGuard ( m_aMutex ); - - if ( bbeforeProgress ) { - pTextList = &maTextlist_Top; - } - else - { - pTextList = &maTextlist_Bottom; - } + MutexGuard aGuard(m_aMutex); + if (bbeforeProgress) + { + pTextList = &maTextlist_Top; + } + else + { + pTextList = &maTextlist_Bottom; + } + } // Switch off guard. - aGuard.clear (); // Search the topic in textlist. size_t nPosition = 0; diff --git a/accessibility/source/extended/AccessibleBrowseBoxBase.cxx b/accessibility/source/extended/AccessibleBrowseBoxBase.cxx index 488d42f7c68c..f8d733c3e30b 100644 --- a/accessibility/source/extended/AccessibleBrowseBoxBase.cxx +++ b/accessibility/source/extended/AccessibleBrowseBoxBase.cxx @@ -414,7 +414,7 @@ tools::Rectangle AccessibleBrowseBoxBase::getBoundingBoxOnScreen() void AccessibleBrowseBoxBase::commitEvent( sal_Int16 _nEventId, const Any& _rNewValue, const Any& _rOldValue ) { - ::osl::ClearableMutexGuard aGuard( getMutex() ); + osl::MutexGuard aGuard( getMutex() ); if ( !getClientId( ) ) // if we don't have a client id for the notifier, then we don't have listeners, then // we don't need to notify anything diff --git a/accessibility/source/extended/textwindowaccessibility.cxx b/accessibility/source/extended/textwindowaccessibility.cxx index 927895339a7e..3cebc2ba295e 100644 --- a/accessibility/source/extended/textwindowaccessibility.cxx +++ b/accessibility/source/extended/textwindowaccessibility.cxx @@ -589,7 +589,7 @@ void SAL_CALL Paragraph::removeAccessibleEventListener( { comphelper::AccessibleEventNotifier::TClientId nId = 0; { - ::osl::ClearableMutexGuard aGuard(rBHelper.rMutex); + osl::MutexGuard aGuard(rBHelper.rMutex); if (rListener.is() && m_nClientId != 0 && comphelper::AccessibleEventNotifier::removeEventListener( m_nClientId, rListener ) == 0) { @@ -612,7 +612,7 @@ void SAL_CALL Paragraph::disposing() { comphelper::AccessibleEventNotifier::TClientId nId = 0; { - ::osl::ClearableMutexGuard aGuard(rBHelper.rMutex); + osl::MutexGuard aGuard(rBHelper.rMutex); nId = m_nClientId; m_nClientId = 0; } diff --git a/chart2/source/controller/accessibility/AccessibleBase.cxx b/chart2/source/controller/accessibility/AccessibleBase.cxx index ce2c5769c812..281c86ca203d 100644 --- a/chart2/source/controller/accessibility/AccessibleBase.cxx +++ b/chart2/source/controller/accessibility/AccessibleBase.cxx @@ -56,7 +56,6 @@ using ::com::sun::star::uno::UNO_QUERY; using ::com::sun::star::uno::Reference; using ::osl::MutexGuard; using ::osl::ClearableMutexGuard; -using ::osl::ResettableMutexGuard; using ::com::sun::star::uno::Any; namespace chart @@ -412,29 +411,31 @@ void AccessibleBase::SetInfo( const AccessibleElementInfo & rNewInfo ) // ________ (XComponent::dispose) ________ void SAL_CALL AccessibleBase::disposing() { - ClearableMutexGuard aGuard( GetMutex() ); - OSL_ENSURE( ! m_bIsDisposed, "dispose() called twice" ); - - // notify disposing to all AccessibleEvent listeners asynchron - if ( m_nEventNotifierId ) { - ::comphelper::AccessibleEventNotifier::revokeClientNotifyDisposing( m_nEventNotifierId, *this ); - m_nEventNotifierId = 0; - } + MutexGuard aGuard(GetMutex()); + OSL_ENSURE(!m_bIsDisposed, "dispose() called twice"); + + // notify disposing to all AccessibleEvent listeners asynchron + if (m_nEventNotifierId) + { + ::comphelper::AccessibleEventNotifier::revokeClientNotifyDisposing(m_nEventNotifierId, + *this); + m_nEventNotifierId = 0; + } - // reset pointers - m_aAccInfo.m_pParent = nullptr; + // reset pointers + m_aAccInfo.m_pParent = nullptr; - // attach new empty state set helper to member reference - ::utl::AccessibleStateSetHelper * pHelper = new ::utl::AccessibleStateSetHelper(); - pHelper->AddState( AccessibleStateType::DEFUNC ); - // release old helper and attach new one - m_xStateSetHelper = pHelper; + // attach new empty state set helper to member reference + ::utl::AccessibleStateSetHelper * pHelper = new ::utl::AccessibleStateSetHelper(); + pHelper->AddState(AccessibleStateType::DEFUNC); + // release old helper and attach new one + m_xStateSetHelper = pHelper; - m_bIsDisposed = true; + m_bIsDisposed = true; + } // call listeners unguarded - aGuard.clear(); if( m_bMayHaveChildren ) { @@ -480,7 +481,7 @@ Reference< XAccessible > SAL_CALL AccessibleBase::getAccessibleChild( sal_Int32 CheckDisposeState(); Reference< XAccessible > xResult; - ResettableMutexGuard aGuard( GetMutex() ); + ClearableMutexGuard aGuard( GetMutex() ); bool bMustUpdateChildren = ( m_bMayHaveChildren && ! m_bChildrenInitialized ); diff --git a/chart2/source/view/main/ChartView.cxx b/chart2/source/view/main/ChartView.cxx index b2e493e8d46e..872406f9f16b 100644 --- a/chart2/source/view/main/ChartView.cxx +++ b/chart2/source/view/main/ChartView.cxx @@ -2453,7 +2453,7 @@ void ChartView::createShapes() { SolarMutexGuard aSolarGuard; - osl::ResettableMutexGuard aTimedGuard(maTimeMutex); + osl::MutexGuard aTimedGuard(maTimeMutex); if(mrChartModel.isTimeBased()) { maTimeBased.bTimeBased = true; @@ -2927,7 +2927,7 @@ OUString ChartView::dump() void ChartView::setViewDirty() { - osl::ResettableMutexGuard aGuard(maTimeMutex); + osl::MutexGuard aGuard(maTimeMutex); m_bViewDirty = true; } diff --git a/comphelper/source/container/enumhelper.cxx b/comphelper/source/container/enumhelper.cxx index b62838d3b39c..41585ae24a8a 100644 --- a/comphelper/source/container/enumhelper.cxx +++ b/comphelper/source/container/enumhelper.cxx @@ -53,7 +53,7 @@ OEnumerationByName::~OEnumerationByName() sal_Bool SAL_CALL OEnumerationByName::hasMoreElements( ) { - ::osl::ResettableMutexGuard aLock(m_aLock); + osl::MutexGuard aLock(m_aLock); if (m_xAccess.is() && m_aNames.getLength() > m_nPos) return true; @@ -70,7 +70,7 @@ sal_Bool SAL_CALL OEnumerationByName::hasMoreElements( ) css::uno::Any SAL_CALL OEnumerationByName::nextElement( ) { - ::osl::ResettableMutexGuard aLock(m_aLock); + osl::MutexGuard aLock(m_aLock); css::uno::Any aRes; if (m_xAccess.is() && m_nPos < m_aNames.getLength()) @@ -91,7 +91,7 @@ css::uno::Any SAL_CALL OEnumerationByName::nextElement( ) void SAL_CALL OEnumerationByName::disposing(const css::lang::EventObject& aEvent) { - ::osl::ResettableMutexGuard aLock(m_aLock); + osl::MutexGuard aLock(m_aLock); if (aEvent.Source == m_xAccess) m_xAccess.clear(); @@ -100,7 +100,7 @@ void SAL_CALL OEnumerationByName::disposing(const css::lang::EventObject& aEvent void OEnumerationByName::impl_startDisposeListening() { - ::osl::ResettableMutexGuard aLock(m_aLock); + osl::MutexGuard aLock(m_aLock); if (m_bListening) return; @@ -118,7 +118,7 @@ void OEnumerationByName::impl_startDisposeListening() void OEnumerationByName::impl_stopDisposeListening() { - ::osl::ResettableMutexGuard aLock(m_aLock); + osl::MutexGuard aLock(m_aLock); if (!m_bListening) return; @@ -150,7 +150,7 @@ OEnumerationByIndex::~OEnumerationByIndex() sal_Bool SAL_CALL OEnumerationByIndex::hasMoreElements( ) { - ::osl::ResettableMutexGuard aLock(m_aLock); + osl::MutexGuard aLock(m_aLock); if (m_xAccess.is() && m_xAccess->getCount() > m_nPos) return true; @@ -167,7 +167,7 @@ sal_Bool SAL_CALL OEnumerationByIndex::hasMoreElements( ) css::uno::Any SAL_CALL OEnumerationByIndex::nextElement( ) { - ::osl::ResettableMutexGuard aLock(m_aLock); + osl::MutexGuard aLock(m_aLock); css::uno::Any aRes; if (m_xAccess.is() && m_nPos < m_xAccess->getCount()) @@ -187,7 +187,7 @@ css::uno::Any SAL_CALL OEnumerationByIndex::nextElement( ) void SAL_CALL OEnumerationByIndex::disposing(const css::lang::EventObject& aEvent) { - ::osl::ResettableMutexGuard aLock(m_aLock); + osl::MutexGuard aLock(m_aLock); if (aEvent.Source == m_xAccess) m_xAccess.clear(); @@ -196,7 +196,7 @@ void SAL_CALL OEnumerationByIndex::disposing(const css::lang::EventObject& aEven void OEnumerationByIndex::impl_startDisposeListening() { - ::osl::ResettableMutexGuard aLock(m_aLock); + osl::MutexGuard aLock(m_aLock); if (m_bListening) return; @@ -214,7 +214,7 @@ void OEnumerationByIndex::impl_startDisposeListening() void OEnumerationByIndex::impl_stopDisposeListening() { - ::osl::ResettableMutexGuard aLock(m_aLock); + osl::MutexGuard aLock(m_aLock); if (!m_bListening) return; @@ -243,7 +243,7 @@ OAnyEnumeration::~OAnyEnumeration() sal_Bool SAL_CALL OAnyEnumeration::hasMoreElements( ) { - ::osl::ResettableMutexGuard aLock(m_aLock); + osl::MutexGuard aLock(m_aLock); return (m_lItems.getLength() > m_nPos); } @@ -254,7 +254,7 @@ css::uno::Any SAL_CALL OAnyEnumeration::nextElement( ) if ( ! hasMoreElements()) throw css::container::NoSuchElementException(); - ::osl::ResettableMutexGuard aLock(m_aLock); + osl::MutexGuard aLock(m_aLock); sal_Int32 nPos = m_nPos; ++m_nPos; return m_lItems[nPos]; diff --git a/comphelper/source/misc/instancelocker.cxx b/comphelper/source/misc/instancelocker.cxx index 43991cec43b1..c995499d8410 100644 --- a/comphelper/source/misc/instancelocker.cxx +++ b/comphelper/source/misc/instancelocker.cxx @@ -211,7 +211,7 @@ OLockListener::~OLockListener() void OLockListener::Dispose() { - ::osl::ResettableMutexGuard aGuard( m_aMutex ); + osl::MutexGuard aGuard( m_aMutex ); if ( m_bDisposed ) return; @@ -251,7 +251,7 @@ void OLockListener::Dispose() void SAL_CALL OLockListener::disposing( const lang::EventObject& aEvent ) { - ::osl::ResettableMutexGuard aGuard( m_aMutex ); + osl::ClearableMutexGuard aGuard( m_aMutex ); // object is disposed if ( aEvent.Source == m_xInstance ) @@ -276,7 +276,7 @@ void SAL_CALL OLockListener::disposing( const lang::EventObject& aEvent ) void SAL_CALL OLockListener::queryClosing( const lang::EventObject& aEvent, sal_Bool ) { // GetsOwnership parameter is always ignored, the user of the service must close the object always - ::osl::ResettableMutexGuard aGuard( m_aMutex ); + osl::ClearableMutexGuard aGuard( m_aMutex ); if ( !m_bDisposed && aEvent.Source == m_xInstance && ( m_nMode & embed::Actions::PREVENT_CLOSE ) ) { try @@ -304,7 +304,7 @@ void SAL_CALL OLockListener::queryClosing( const lang::EventObject& aEvent, sal_ void SAL_CALL OLockListener::notifyClosing( const lang::EventObject& aEvent ) { - ::osl::ResettableMutexGuard aGuard( m_aMutex ); + osl::ClearableMutexGuard aGuard( m_aMutex ); // object is closed, no reason to listen if ( aEvent.Source == m_xInstance ) @@ -334,7 +334,7 @@ void SAL_CALL OLockListener::notifyClosing( const lang::EventObject& aEvent ) void SAL_CALL OLockListener::queryTermination( const lang::EventObject& aEvent ) { - ::osl::ResettableMutexGuard aGuard( m_aMutex ); + osl::ClearableMutexGuard aGuard( m_aMutex ); if ( aEvent.Source == m_xInstance && ( m_nMode & embed::Actions::PREVENT_TERMINATION ) ) { try @@ -362,7 +362,7 @@ void SAL_CALL OLockListener::queryTermination( const lang::EventObject& aEvent ) void SAL_CALL OLockListener::notifyTermination( const lang::EventObject& aEvent ) { - ::osl::ResettableMutexGuard aGuard( m_aMutex ); + osl::ClearableMutexGuard aGuard( m_aMutex ); // object is terminated, no reason to listen if ( aEvent.Source == m_xInstance ) @@ -397,7 +397,7 @@ void SAL_CALL OLockListener::notifyTermination( const lang::EventObject& aEvent void OLockListener::Init() { - ::osl::ResettableMutexGuard aGuard( m_aMutex ); + osl::ClearableMutexGuard aGuard( m_aMutex ); if ( m_bDisposed || m_bInitialized ) return; diff --git a/comphelper/source/misc/numberedcollection.cxx b/comphelper/source/misc/numberedcollection.cxx index 43aa31f972ec..81533aa7b249 100644 --- a/comphelper/source/misc/numberedcollection.cxx +++ b/comphelper/source/misc/numberedcollection.cxx @@ -44,7 +44,7 @@ NumberedCollection::~NumberedCollection() void NumberedCollection::setOwner(const css::uno::Reference< css::uno::XInterface >& xOwner) { // SYNCHRONIZED -> - ::osl::ResettableMutexGuard aLock(m_aMutex); + osl::MutexGuard aLock(m_aMutex); m_xOwner = xOwner; @@ -55,7 +55,7 @@ void NumberedCollection::setOwner(const css::uno::Reference< css::uno::XInterfac void NumberedCollection::setUntitledPrefix(const OUString& sPrefix) { // SYNCHRONIZED -> - ::osl::ResettableMutexGuard aLock(m_aMutex); + osl::MutexGuard aLock(m_aMutex); m_sUntitledPrefix = sPrefix; @@ -66,7 +66,7 @@ void NumberedCollection::setUntitledPrefix(const OUString& sPrefix) ::sal_Int32 SAL_CALL NumberedCollection::leaseNumber(const css::uno::Reference< css::uno::XInterface >& xComponent) { // SYNCHRONIZED -> - ::osl::ResettableMutexGuard aLock(m_aMutex); + osl::MutexGuard aLock(m_aMutex); if ( ! xComponent.is ()) throw css::lang::IllegalArgumentException(ERRMSG_INVALID_COMPONENT_PARAM, m_xOwner.get(), 1); @@ -101,7 +101,7 @@ void NumberedCollection::setUntitledPrefix(const OUString& sPrefix) void SAL_CALL NumberedCollection::releaseNumber(::sal_Int32 nNumber) { // SYNCHRONIZED -> - ::osl::ResettableMutexGuard aLock(m_aMutex); + osl::MutexGuard aLock(m_aMutex); if (nNumber == css::frame::UntitledNumbersConst::INVALID_NUMBER) throw css::lang::IllegalArgumentException ("Special valkud INVALID_NUMBER not allowed as input parameter.", m_xOwner.get(), 1); @@ -138,7 +138,7 @@ void SAL_CALL NumberedCollection::releaseNumber(::sal_Int32 nNumber) void SAL_CALL NumberedCollection::releaseNumberForComponent(const css::uno::Reference< css::uno::XInterface >& xComponent) { // SYNCHRONIZED -> - ::osl::ResettableMutexGuard aLock(m_aMutex); + osl::MutexGuard aLock(m_aMutex); if ( ! xComponent.is ()) throw css::lang::IllegalArgumentException(ERRMSG_INVALID_COMPONENT_PARAM, m_xOwner.get(), 1); @@ -160,7 +160,7 @@ void SAL_CALL NumberedCollection::releaseNumberForComponent(const css::uno::Refe OUString SAL_CALL NumberedCollection::getUntitledPrefix() { // SYNCHRONIZED -> - ::osl::ResettableMutexGuard aLock(m_aMutex); + osl::MutexGuard aLock(m_aMutex); return m_sUntitledPrefix; @@ -195,8 +195,8 @@ OUString SAL_CALL NumberedCollection::getUntitledPrefix() lPossibleNumbers.push_back (i); // SYNCHRONIZED -> - ::osl::ResettableMutexGuard aLock(m_aMutex); { + osl::MutexGuard aLock(m_aMutex); TDeadItemList lDeadItems; for (const auto& [rComponent, rItem] : m_lComponents) diff --git a/comphelper/source/property/genericpropertyset.cxx b/comphelper/source/property/genericpropertyset.cxx index af224f822ede..5ce75e30323a 100644 --- a/comphelper/source/property/genericpropertyset.cxx +++ b/comphelper/source/property/genericpropertyset.cxx @@ -117,7 +117,7 @@ void SAL_CALL GenericPropertySet::addPropertyChangeListener( const OUString& aPr void SAL_CALL GenericPropertySet::removePropertyChangeListener( const OUString& aPropertyName, const Reference< XPropertyChangeListener >& xListener ) { - ResettableMutexGuard aGuard( maMutex ); + ClearableMutexGuard aGuard( maMutex ); Reference < XPropertySetInfo > xInfo = getPropertySetInfo( ); aGuard.clear(); if ( xInfo.is() ) diff --git a/comphelper/source/property/opropertybag.cxx b/comphelper/source/property/opropertybag.cxx index 43dfc4cfdc71..fd5807fae03f 100644 --- a/comphelper/source/property/opropertybag.cxx +++ b/comphelper/source/property/opropertybag.cxx @@ -208,21 +208,21 @@ namespace comphelper if ( !( _element >>= aProperty ) ) throw IllegalArgumentException( OUString(), *this, 1 ); - ::osl::ClearableMutexGuard g( m_aMutex ); - - // check whether the type is allowed, everything else will be checked - // by m_aDynamicProperties - if ( !m_aAllowedTypes.empty() - && m_aAllowedTypes.find( aProperty.Type ) == m_aAllowedTypes.end() - ) - throw IllegalArgumentException( OUString(), *this, 1 ); + { + osl::MutexGuard g(m_aMutex); - m_aDynamicProperties.addVoidProperty( aProperty.Name, aProperty.Type, findFreeHandle(), aProperty.Attributes ); + // check whether the type is allowed, everything else will be checked + // by m_aDynamicProperties + if (!m_aAllowedTypes.empty() + && m_aAllowedTypes.find(aProperty.Type) == m_aAllowedTypes.end()) + throw IllegalArgumentException(OUString(), *this, 1); - // our property info is dirty - m_pArrayHelper.reset(); + m_aDynamicProperties.addVoidProperty(aProperty.Name, aProperty.Type, findFreeHandle(), + aProperty.Attributes); - g.clear(); + // our property info is dirty + m_pArrayHelper.reset(); + } setModified(true); } @@ -312,37 +312,36 @@ namespace comphelper void SAL_CALL OPropertyBag::addProperty( const OUString& _rName, ::sal_Int16 _nAttributes, const Any& _rInitialValue ) { - ::osl::ClearableMutexGuard g( m_aMutex ); - - // check whether the type is allowed, everything else will be checked - // by m_aDynamicProperties - const Type& aPropertyType = _rInitialValue.getValueType(); - if ( _rInitialValue.hasValue() - && !m_aAllowedTypes.empty() - && m_aAllowedTypes.find( aPropertyType ) == m_aAllowedTypes.end() - ) - throw IllegalTypeException( OUString(), *this ); + { + osl::MutexGuard g(m_aMutex); - m_aDynamicProperties.addProperty( _rName, findFreeHandle(), _nAttributes, _rInitialValue ); + // check whether the type is allowed, everything else will be checked + // by m_aDynamicProperties + const Type& aPropertyType = _rInitialValue.getValueType(); + if (_rInitialValue.hasValue() && !m_aAllowedTypes.empty() + && m_aAllowedTypes.find(aPropertyType) == m_aAllowedTypes.end()) + throw IllegalTypeException(OUString(), *this); - // our property info is dirty - m_pArrayHelper.reset(); + m_aDynamicProperties.addProperty(_rName, findFreeHandle(), _nAttributes, + _rInitialValue); - g.clear(); + // our property info is dirty + m_pArrayHelper.reset(); + } setModified(true); } void SAL_CALL OPropertyBag::removeProperty( const OUString& _rName ) { - ::osl::ClearableMutexGuard g( m_aMutex ); - - m_aDynamicProperties.removeProperty( _rName ); + { + osl::MutexGuard g(m_aMutex); - // our property info is dirty - m_pArrayHelper.reset(); + m_aDynamicProperties.removeProperty(_rName); - g.clear(); + // our property info is dirty + m_pArrayHelper.reset(); + } setModified(true); } diff --git a/dbaccess/source/core/api/statement.cxx b/dbaccess/source/core/api/statement.cxx index 3bad447db85f..beac6a16c13c 100644 --- a/dbaccess/source/core/api/statement.cxx +++ b/dbaccess/source/core/api/statement.cxx @@ -307,7 +307,7 @@ void OStatementBase::clearWarnings() void OStatementBase::cancel() { // no blocking as cancel is typically called from a different thread - ClearableMutexGuard aCancelGuard(m_aCancelMutex); + MutexGuard aCancelGuard(m_aCancelMutex); if (m_xAggregateAsCancellable.is()) m_xAggregateAsCancellable->cancel(); // else do nothing diff --git a/dbaccess/source/core/dataaccess/databasedocument.cxx b/dbaccess/source/core/dataaccess/databasedocument.cxx index ad3713a1f43e..3c299261e438 100644 --- a/dbaccess/source/core/dataaccess/databasedocument.cxx +++ b/dbaccess/source/core/dataaccess/databasedocument.cxx @@ -1804,52 +1804,54 @@ void ODatabaseDocument::disposing() std::vector< Reference< XInterface > > aKeepAlive; // SYNCHRONIZED -> - SolarMutexClearableGuard aGuard; - - OSL_ENSURE( m_aControllers.empty(), "ODatabaseDocument::disposing: there still are controllers!" ); - // normally, nobody should explicitly dispose, but only XCloseable::close - // the document. And upon closing, our controllers are closed, too - { - uno::Reference<uno::XInterface> xUIInterface( m_xUIConfigurationManager ); - aKeepAlive.push_back( xUIInterface ); - } - m_xUIConfigurationManager = nullptr; + SolarMutexGuard aGuard; - clearObjectContainer( m_xForms ); - clearObjectContainer( m_xReports ); + OSL_ENSURE(m_aControllers.empty(), + "ODatabaseDocument::disposing: there still are controllers!"); + // normally, nobody should explicitly dispose, but only XCloseable::close + // the document. And upon closing, our controllers are closed, too - // reset the macro mode: in case the our impl struct stays alive (e.g. because our DataSource - // object still exists), and somebody subsequently re-opens the document, we want to have - // the security warning, again. - m_pImpl->resetMacroExecutionMode(); + { + uno::Reference<uno::XInterface> xUIInterface(m_xUIConfigurationManager); + aKeepAlive.push_back(xUIInterface); + } + m_xUIConfigurationManager = nullptr; - // similar arguing for our ViewMonitor - m_aViewMonitor.reset(); + clearObjectContainer(m_xForms); + clearObjectContainer(m_xReports); - // tell our Impl to forget us - m_pImpl->modelIsDisposing( impl_isInitialized(), ODatabaseModelImpl::ResetModelAccess() ); + // reset the macro mode: in case the our impl struct stays alive (e.g. because our DataSource + // object still exists), and somebody subsequently re-opens the document, we want to have + // the security warning, again. + m_pImpl->resetMacroExecutionMode(); - // now, at the latest, the controller array should be empty. Controllers are - // expected to listen for our disposal, and disconnect then - OSL_ENSURE( m_aControllers.empty(), "ODatabaseDocument::disposing: there still are controllers!" ); - impl_disposeControllerFrames_nothrow(); + // similar arguing for our ViewMonitor + m_aViewMonitor.reset(); - { - uno::Reference<uno::XInterface> xModuleInterface( m_xModuleManager ); - aKeepAlive.push_back( xModuleInterface ); - } - m_xModuleManager.clear(); + // tell our Impl to forget us + m_pImpl->modelIsDisposing(impl_isInitialized(), ODatabaseModelImpl::ResetModelAccess()); - { - uno::Reference<uno::XInterface> xTitleInterface( m_xTitleHelper ); - aKeepAlive.push_back( xTitleInterface ); - } - m_xTitleHelper.clear(); + // now, at the latest, the controller array should be empty. Controllers are + // expected to listen for our disposal, and disconnect then + OSL_ENSURE(m_aControllers.empty(), + "ODatabaseDocument::disposing: there still are controllers!"); + impl_disposeControllerFrames_nothrow(); - m_pImpl.clear(); + { + uno::Reference<uno::XInterface> xModuleInterface(m_xModuleManager); + aKeepAlive.push_back(xModuleInterface); + } + m_xModuleManager.clear(); - aGuard.clear(); + { + uno::Reference<uno::XInterface> xTitleInterface(m_xTitleHelper); + aKeepAlive.push_back(xTitleInterface); + } + m_xTitleHelper.clear(); + + m_pImpl.clear(); + } // <- SYNCHRONIZED aKeepAlive.clear(); diff --git a/dbaccess/source/core/dataaccess/definitioncontainer.cxx b/dbaccess/source/core/dataaccess/definitioncontainer.cxx index 4acaa00fcc52..c099c0fe8e84 100644 --- a/dbaccess/source/core/dataaccess/definitioncontainer.cxx +++ b/dbaccess/source/core/dataaccess/definitioncontainer.cxx @@ -605,7 +605,7 @@ void ODefinitionContainer::approveNewObject(const OUString& _sName,const Referen // XPropertyChangeListener void SAL_CALL ODefinitionContainer::propertyChange( const PropertyChangeEvent& evt ) { - ClearableMutexGuard aGuard(m_aMutex); + MutexGuard aGuard(m_aMutex); if( evt.PropertyName == PROPERTY_NAME || evt.PropertyName == "Title" ) { m_bInPropertyChange = true; diff --git a/dbaccess/source/core/dataaccess/documentcontainer.cxx b/dbaccess/source/core/dataaccess/documentcontainer.cxx index bcb128145ffe..992eb24e5759 100644 --- a/dbaccess/source/core/dataaccess/documentcontainer.cxx +++ b/dbaccess/source/core/dataaccess/documentcontainer.cxx @@ -565,7 +565,7 @@ void SAL_CALL ODocumentContainer::insertByHierarchicalName( const OUString& _sNa if ( !xContent.is() ) throw IllegalArgumentException(); - ClearableMutexGuard aGuard(m_aMutex); + MutexGuard aGuard(m_aMutex); Any aContent; Reference< XNameContainer > xNameContainer(this); OUString sName; @@ -589,7 +589,7 @@ void SAL_CALL ODocumentContainer::removeByHierarchicalName( const OUString& _sNa if ( _sName.isEmpty() ) throw NoSuchElementException(_sName,*this); - ClearableMutexGuard aGuard(m_aMutex); + MutexGuard aGuard(m_aMutex); Any aContent; OUString sName; Reference< XNameContainer > xNameContainer(this); @@ -606,7 +606,7 @@ void SAL_CALL ODocumentContainer::replaceByHierarchicalName( const OUString& _sN if ( !xContent.is() ) throw IllegalArgumentException(); - ClearableMutexGuard aGuard(m_aMutex); + MutexGuard aGuard(m_aMutex); Any aContent; OUString sName; Reference< XNameContainer > xNameContainer(this); diff --git a/dbaccess/source/core/dataaccess/documentdefinition.cxx b/dbaccess/source/core/dataaccess/documentdefinition.cxx index c69d42b2418f..d367b058af44 100644 --- a/dbaccess/source/core/dataaccess/documentdefinition.cxx +++ b/dbaccess/source/core/dataaccess/documentdefinition.cxx @@ -959,7 +959,7 @@ Any SAL_CALL ODocumentDefinition::execute( const Command& aCommand, sal_Int32 Co // making it release the own mutex before calling SolarMutex-code is ... difficult, at least. // So, to be on the same side, we lock the SolarMutex here. Yes, it sucks. ::SolarMutexGuard aSolarGuard; - ::osl::ClearableMutexGuard aGuard(m_aMutex); + osl::MutexGuard aGuard(m_aMutex); if ( m_bInExecute ) return aRet; @@ -994,7 +994,7 @@ Any SAL_CALL ODocumentDefinition::execute( const Command& aCommand, sal_Int32 Co return onCommandOpenSomething( aCommand.Argument, bActivateObject, Environment ); } - ::osl::ClearableMutexGuard aGuard(m_aMutex); + osl::MutexGuard aGuard(m_aMutex); if ( m_bInExecute ) return aRet; diff --git a/dbaccess/source/ui/misc/dbaundomanager.cxx b/dbaccess/source/ui/misc/dbaundomanager.cxx index bff6e03b3609..76f6e7508b06 100644 --- a/dbaccess/source/ui/misc/dbaundomanager.cxx +++ b/dbaccess/source/ui/misc/dbaundomanager.cxx @@ -128,7 +128,7 @@ namespace dbaui virtual ::framework::IMutex& getGuardedMutex() override; private: - ::osl::ResettableMutexGuard m_aGuard; + osl::ClearableMutexGuard m_aGuard; OslMutexFacade m_aMutexFacade; }; diff --git a/desktop/source/app/dispatchwatcher.cxx b/desktop/source/app/dispatchwatcher.cxx index 872d98333982..5393b07e130d 100644 --- a/desktop/source/app/dispatchwatcher.cxx +++ b/desktop/source/app/dispatchwatcher.cxx @@ -406,7 +406,7 @@ bool DispatchWatcher::executeDispatchRequests( const std::vector<DispatchRequest if( xDispatcher.is() ) { { - ::osl::ClearableMutexGuard aGuard(m_mutex); + osl::MutexGuard aGuard(m_mutex); // Remember request so we can find it in statusChanged! m_nRequestCount++; } @@ -754,9 +754,10 @@ bool DispatchWatcher::executeDispatchRequests( const std::vector<DispatchRequest xDisp->dispatchWithNotification( aDispatche.aURL, aArgs, this ); else { - ::osl::ClearableMutexGuard aGuard(m_mutex); - m_nRequestCount--; - aGuard.clear(); + { + osl::MutexGuard aGuard(m_mutex); + m_nRequestCount--; + } xDispatch->dispatch( aDispatche.aURL, aArgs ); } } diff --git a/desktop/source/deployment/gui/dp_gui_extlistbox.cxx b/desktop/source/deployment/gui/dp_gui_extlistbox.cxx index c37ec6945d93..6e13917875c8 100644 --- a/desktop/source/deployment/gui/dp_gui_extlistbox.cxx +++ b/desktop/source/deployment/gui/dp_gui_extlistbox.cxx @@ -920,38 +920,39 @@ void ExtensionBox_Impl::addEntry( const uno::Reference< deployment::XPackage > & if ( pEntry->m_sTitle.isEmpty() ) return; - ::osl::ClearableMutexGuard guard(m_entriesMutex); - if ( m_vEntries.empty() ) - { - addEventListenerOnce(xPackage); - m_vEntries.push_back( pEntry ); - } - else { - if ( !FindEntryPos( pEntry, 0, m_vEntries.size()-1, nPos ) ) + osl::MutexGuard guard(m_entriesMutex); + if (m_vEntries.empty()) { addEventListenerOnce(xPackage); - m_vEntries.insert( m_vEntries.begin()+nPos, pEntry ); + m_vEntries.push_back(pEntry); } - else if ( !m_bInCheckMode ) + else { - OSL_FAIL( "ExtensionBox_Impl::addEntry(): Will not add duplicate entries" ); + if (!FindEntryPos(pEntry, 0, m_vEntries.size() - 1, nPos)) + { + addEventListenerOnce(xPackage); + m_vEntries.insert(m_vEntries.begin() + nPos, pEntry); + } + else if (!m_bInCheckMode) + { + OSL_FAIL("ExtensionBox_Impl::addEntry(): Will not add duplicate entries"); + } } - } - pEntry->m_bHasOptions = m_pManager->supportsOptions( xPackage ); - pEntry->m_bUser = (xPackage->getRepositoryName() == USER_PACKAGE_MANAGER); - pEntry->m_bShared = (xPackage->getRepositoryName() == SHARED_PACKAGE_MANAGER); - pEntry->m_bNew = m_bInCheckMode; - pEntry->m_bMissingLic = bLicenseMissing; + pEntry->m_bHasOptions = m_pManager->supportsOptions(xPackage); + pEntry->m_bUser = (xPackage->getRepositoryName() == USER_PACKAGE_MANAGER); + pEntry->m_bShared = (xPackage->getRepositoryName() == SHARED_PACKAGE_MANAGER); + pEntry->m_bNew = m_bInCheckMode; + pEntry->m_bMissingLic = bLicenseMissing; - if ( bLicenseMissing ) - pEntry->m_sErrorText = DpResId( RID_STR_ERROR_MISSING_LICENSE ); + if (bLicenseMissing) + pEntry->m_sErrorText = DpResId(RID_STR_ERROR_MISSING_LICENSE); - //access to m_nActive must be guarded - if ( !m_bInCheckMode && m_bHasActive && ( m_nActive >= nPos ) ) - m_nActive += 1; - guard.clear(); + //access to m_nActive must be guarded + if (!m_bInCheckMode && m_bHasActive && (m_nActive >= nPos)) + m_nActive += 1; + } if ( IsReallyVisible() ) Invalidate(); @@ -1087,47 +1088,50 @@ void ExtensionBox_Impl::checkEntries() long nPos = 0; bool bNeedsUpdate = false; - ::osl::ClearableMutexGuard guard(m_entriesMutex); - auto iIndex = m_vEntries.begin(); - while ( iIndex != m_vEntries.end() ) { - if ( !(*iIndex)->m_bChecked ) + osl::MutexGuard guard(m_entriesMutex); + auto iIndex = m_vEntries.begin(); + while (iIndex != m_vEntries.end()) { - (*iIndex)->m_bChecked = true; - bNeedsUpdate = true; - nPos = iIndex-m_vEntries.begin(); - if ( (*iIndex)->m_bNew ) - { // add entry to list and correct active pos - if ( nNewPos == - 1) - nNewPos = nPos; - if ( nPos <= m_nActive ) - m_nActive += 1; - ++iIndex; - } - else - { // remove entry from list - if (nPos < nNewPos) { - --nNewPos; - } - if (nPos < nChangedActivePos) { - --nChangedActivePos; + if (!(*iIndex)->m_bChecked) + { + (*iIndex)->m_bChecked = true; + bNeedsUpdate = true; + nPos = iIndex - m_vEntries.begin(); + if ((*iIndex)->m_bNew) + { // add entry to list and correct active pos + if (nNewPos == -1) + nNewPos = nPos; + if (nPos <= m_nActive) + m_nActive += 1; + ++iIndex; } - if ( nPos < m_nActive ) - m_nActive -= 1; - else if ( nPos == m_nActive ) - { - nChangedActivePos = nPos; - m_nActive = -1; - m_bHasActive = false; + else + { // remove entry from list + if (nPos < nNewPos) + { + --nNewPos; + } + if (nPos < nChangedActivePos) + { + --nChangedActivePos; + } + if (nPos < m_nActive) + m_nActive -= 1; + else if (nPos == m_nActive) + { + nChangedActivePos = nPos; + m_nActive = -1; + m_bHasActive = false; + } + m_vRemovedEntries.push_back(*iIndex); + iIndex = m_vEntries.erase(iIndex); } - m_vRemovedEntries.push_back( *iIndex ); - iIndex = m_vEntries.erase( iIndex ); } + else + ++iIndex; } - else - ++iIndex; } - guard.clear(); m_bInCheckMode = false; diff --git a/desktop/source/offacc/acceptor.cxx b/desktop/source/offacc/acceptor.cxx index d806ea7471e6..894f20623e78 100644 --- a/desktop/source/offacc/acceptor.cxx +++ b/desktop/source/offacc/acceptor.cxx @@ -134,7 +134,7 @@ void Acceptor::run() void Acceptor::initialize( const Sequence<Any>& aArguments ) { // prevent multiple initialization - osl::ClearableMutexGuard aGuard( m_aMutex ); + osl::MutexGuard aGuard( m_aMutex ); SAL_INFO( "desktop.offacc", "Acceptor::initialize()" ); bool bOk = false; diff --git a/desktop/source/splash/splash.cxx b/desktop/source/splash/splash.cxx index 195539060b81..64af4ce7fd6a 100644 --- a/desktop/source/splash/splash.cxx +++ b/desktop/source/splash/splash.cxx @@ -250,7 +250,7 @@ void SAL_CALL SplashScreen::setValue(sal_Int32 nValue) void SAL_CALL SplashScreen::initialize( const css::uno::Sequence< css::uno::Any>& aArguments ) { - ::osl::ClearableMutexGuard aGuard( _aMutex ); + osl::MutexGuard aGuard( _aMutex ); if (aArguments.getLength() > 0) { aArguments[0] >>= _bVisible; diff --git a/dtrans/source/win32/clipb/MtaOleClipb.cxx b/dtrans/source/win32/clipb/MtaOleClipb.cxx index 8b1b07ec7ecd..ea9f6dfb380f 100644 --- a/dtrans/source/win32/clipb/MtaOleClipb.cxx +++ b/dtrans/source/win32/clipb/MtaOleClipb.cxx @@ -494,12 +494,10 @@ LRESULT CMtaOleClipboard::onClipboardUpdate() // registering ourself as clipboard if ( !m_bInRegisterClipViewer ) { - ClearableMutexGuard aGuard( m_ClipboardChangedEventCountMutex ); + MutexGuard aGuard( m_ClipboardChangedEventCountMutex ); m_ClipboardChangedEventCount++; SetEvent( m_hClipboardChangedEvent ); - - aGuard.clear( ); } return 0; diff --git a/dtrans/source/win32/clipb/WinClipbImpl.cxx b/dtrans/source/win32/clipb/WinClipbImpl.cxx index 8df5db4a7d03..7ba04d13c4d8 100644 --- a/dtrans/source/win32/clipb/WinClipbImpl.cxx +++ b/dtrans/source/win32/clipb/WinClipbImpl.cxx @@ -63,9 +63,10 @@ CWinClipbImpl::CWinClipbImpl( const OUString& aClipboardName, CWinClipboard* the CWinClipbImpl::~CWinClipbImpl( ) { - ClearableMutexGuard aGuard( s_aMutex ); - s_pCWinClipbImpl = nullptr; - aGuard.clear( ); + { + MutexGuard aGuard(s_aMutex); + s_pCWinClipbImpl = nullptr; + } unregisterClipboardViewer( ); } @@ -74,16 +75,17 @@ Reference< XTransferable > CWinClipbImpl::getContents( ) { // use the shortcut or create a transferable from // system clipboard - ClearableMutexGuard aGuard( m_ClipContentMutex ); - - if ( nullptr != m_pCurrentClipContent ) { - return m_pCurrentClipContent->m_XTransferable; - } + MutexGuard aGuard(m_ClipContentMutex); - // release the mutex, so that the variable may be - // changed by other threads - aGuard.clear( ); + if (nullptr != m_pCurrentClipContent) + { + return m_pCurrentClipContent->m_XTransferable; + } + + // release the mutex, so that the variable may be + // changed by other threads + } Reference< XTransferable > rClipContent; @@ -112,15 +114,14 @@ void CWinClipbImpl::setContents( if ( xTransferable.is( ) ) { - ClearableMutexGuard aGuard( m_ClipContentMutex ); - - m_pCurrentClipContent = new CXNotifyingDataObject( - CDTransObjFactory::createDataObjFromTransferable( m_pWinClipboard->m_xContext , xTransferable ), - xTransferable, - xClipboardOwner, - this ); - - aGuard.clear( ); + { + MutexGuard aGuard(m_ClipContentMutex); + + m_pCurrentClipContent + = new CXNotifyingDataObject(CDTransObjFactory::createDataObjFromTransferable( + m_pWinClipboard->m_xContext, xTransferable), + xTransferable, xClipboardOwner, this); + } pIDataObj = IDataObjectPtr( m_pCurrentClipContent ); } diff --git a/embeddedobj/source/commonembedding/embedobj.cxx b/embeddedobj/source/commonembedding/embedobj.cxx index a3319d7d828f..98f6a3d11d2b 100644 --- a/embeddedobj/source/commonembedding/embedobj.cxx +++ b/embeddedobj/source/commonembedding/embedobj.cxx @@ -510,7 +510,7 @@ void SAL_CALL OCommonEmbeddedObject::doVerb( sal_Int32 nVerbID ) // to get locking done right in this class, but that looks like a // daunting task - ::osl::ResettableMutexGuard aGuard( m_aMutex ); + osl::ClearableMutexGuard aGuard( m_aMutex ); if ( m_bDisposed ) throw lang::DisposedException(); // TODO diff --git a/embeddedobj/source/msole/olecomponent.cxx b/embeddedobj/source/msole/olecomponent.cxx index 2fa50bd452e0..06f24c9b080c 100644 --- a/embeddedobj/source/msole/olecomponent.cxx +++ b/embeddedobj/source/msole/olecomponent.cxx @@ -460,9 +460,7 @@ OleComponent::~OleComponent() if ( m_pOleWrapClientSite || m_pImplAdviseSink || m_pInterfaceContainer || m_bOleInitialized ) { - ::osl::ClearableMutexGuard aGuard( m_aMutex ); - m_refCount++; - aGuard.clear(); + osl_atomic_increment(&m_refCount); try { Dispose(); } catch( const uno::Exception& ) {} @@ -1418,52 +1416,56 @@ void OleComponent::OnClose_Impl() void SAL_CALL OleComponent::close( sal_Bool bDeliverOwnership ) { - ::osl::ClearableMutexGuard aGuard( m_aMutex ); - if ( m_bDisposed ) - throw lang::DisposedException(); // TODO + uno::Reference< uno::XInterface > xSelfHold; + { + osl::MutexGuard aGuard(m_aMutex); + if (m_bDisposed) + throw lang::DisposedException(); // TODO - uno::Reference< uno::XInterface > xSelfHold( static_cast< ::cppu::OWeakObject* >( this ) ); - lang::EventObject aSource( static_cast< ::cppu::OWeakObject* >( this ) ); + xSelfHold.set(static_cast<::cppu::OWeakObject*>(this)); + lang::EventObject aSource(static_cast<::cppu::OWeakObject*>(this)); - if ( m_pInterfaceContainer ) - { - ::cppu::OInterfaceContainerHelper* pContainer = - m_pInterfaceContainer->getContainer( cppu::UnoType<util::XCloseListener>::get()); - if ( pContainer != nullptr ) + if (m_pInterfaceContainer) { - ::cppu::OInterfaceIteratorHelper pIterator( *pContainer ); - while ( pIterator.hasMoreElements() ) + ::cppu::OInterfaceContainerHelper* pContainer + = m_pInterfaceContainer->getContainer(cppu::UnoType<util::XCloseListener>::get()); + if (pContainer != nullptr) { - try + ::cppu::OInterfaceIteratorHelper pIterator(*pContainer); + while (pIterator.hasMoreElements()) { - static_cast<util::XCloseListener*>( pIterator.next() )->queryClosing( aSource, bDeliverOwnership ); - } - catch( const uno::RuntimeException& ) - { - pIterator.remove(); + try + { + static_cast<util::XCloseListener*>(pIterator.next()) + ->queryClosing(aSource, bDeliverOwnership); + } + catch (const uno::RuntimeException&) + { + pIterator.remove(); + } } } - } - pContainer = m_pInterfaceContainer->getContainer( - cppu::UnoType<util::XCloseListener>::get()); - if ( pContainer != nullptr ) - { - ::cppu::OInterfaceIteratorHelper pCloseIterator( *pContainer ); - while ( pCloseIterator.hasMoreElements() ) + pContainer + = m_pInterfaceContainer->getContainer(cppu::UnoType<util::XCloseListener>::get()); + if (pContainer != nullptr) { - try + ::cppu::OInterfaceIteratorHelper pCloseIterator(*pContainer); + while (pCloseIterator.hasMoreElements()) { - static_cast<util::XCloseListener*>( pCloseIterator.next() )->notifyClosing( aSource ); - } - catch( const uno::RuntimeException& ) - { - pCloseIterator.remove(); + try + { + static_cast<util::XCloseListener*>(pCloseIterator.next()) + ->notifyClosing(aSource); + } + catch (const uno::RuntimeException&) + { + pCloseIterator.remove(); + } } } } } - aGuard.clear(); Dispose(); } diff --git a/embeddedobj/source/msole/olepersist.cxx b/embeddedobj/source/msole/olepersist.cxx index fddb668568b4..763ced642655 100644 --- a/embeddedobj/source/msole/olepersist.cxx +++ b/embeddedobj/source/msole/olepersist.cxx @@ -795,7 +795,7 @@ bool OleEmbeddedObject::SaveObject_Impl() bool OleEmbeddedObject::OnShowWindow_Impl( bool bShow ) { - ::osl::ResettableMutexGuard aGuard( m_aMutex ); + osl::ClearableMutexGuard aGuard(m_aMutex); bool bResult = false; @@ -1507,7 +1507,7 @@ void SAL_CALL OleEmbeddedObject::saveCompleted( sal_Bool bUseNew ) } // end wrapping related part ==================== - ::osl::ResettableMutexGuard aGuard( m_aMutex ); + osl::ClearableMutexGuard aGuard(m_aMutex); if ( m_bDisposed ) throw lang::DisposedException(); // TODO @@ -1665,7 +1665,7 @@ void SAL_CALL OleEmbeddedObject::storeOwn() // ask container to store the object, the container has to make decision // to do so or not - ::osl::ResettableMutexGuard aGuard( m_aMutex ); + osl::ClearableMutexGuard aGuard(m_aMutex); if ( m_bDisposed ) throw lang::DisposedException(); // TODO diff --git a/extensions/source/update/check/updatecheck.cxx b/extensions/source/update/check/updatecheck.cxx index 4306e073e26b..bbeaf3565cac 100644 --- a/extensions/source/update/check/updatecheck.cxx +++ b/extensions/source/update/check/updatecheck.cxx @@ -844,9 +844,10 @@ UpdateCheck::download() { shutdownThread(true); - osl::ClearableMutexGuard aGuard2(m_aMutex); - enableDownload(true); - aGuard2.clear(); + { + osl::MutexGuard aGuard2(m_aMutex); + enableDownload(true); + } setUIState(UPDATESTATE_DOWNLOADING); } } @@ -1051,7 +1052,7 @@ UpdateCheck::downloadTargetExists(const OUString& rFileName) bool UpdateCheck::checkDownloadDestination( const OUString& rFileName ) { - osl::ClearableMutexGuard aGuard(m_aMutex); + osl::MutexGuard aGuard(m_aMutex); rtl::Reference< UpdateHandler > aUpdateHandler( getUpdateHandler() ); diff --git a/filter/source/config/cache/basecontainer.cxx b/filter/source/config/cache/basecontainer.cxx index 53e04e68ecf5..22565b276f65 100644 --- a/filter/source/config/cache/basecontainer.cxx +++ b/filter/source/config/cache/basecontainer.cxx @@ -55,7 +55,7 @@ void BaseContainer::init(const css::uno::Reference< css::uno::XComponentContext FilterCache::EItemType eType ) { // SAFE -> - ::osl::ResettableMutexGuard aLock(m_aLock); + osl::MutexGuard aLock(m_aLock); m_sImplementationName = sImplementationName; m_lServiceNames = lServiceNames ; @@ -69,7 +69,7 @@ void BaseContainer::impl_loadOnDemand() { #ifdef LOAD_IMPLICIT // SAFE -> - ::osl::ResettableMutexGuard aLock(m_aLock); + osl::MutexGuard aLock(m_aLock); // A generic container needs all items of a set of our cache! // Of course it can block for a while, till the cache is really filled. @@ -104,7 +104,7 @@ void BaseContainer::impl_loadOnDemand() void BaseContainer::impl_initFlushMode() { // SAFE -> - ::osl::ResettableMutexGuard aLock(m_aLock); + osl::MutexGuard aLock(m_aLock); if (!m_pFlushCache) m_pFlushCache = TheFilterCache::get().clone(); if (!m_pFlushCache) @@ -117,7 +117,7 @@ void BaseContainer::impl_initFlushMode() FilterCache* BaseContainer::impl_getWorkingCache() const { // SAFE -> - ::osl::ResettableMutexGuard aLock(m_aLock); + osl::MutexGuard aLock(m_aLock); if (m_pFlushCache) return m_pFlushCache.get(); else @@ -164,7 +164,7 @@ void SAL_CALL BaseContainer::insertByName(const OUString& sItem , impl_loadOnDemand(); // SAFE -> ---------------------------------- - ::osl::ResettableMutexGuard aLock(m_aLock); + osl::MutexGuard aLock(m_aLock); // create write copy of used cache on demand ... impl_initFlushMode(); @@ -173,8 +173,6 @@ void SAL_CALL BaseContainer::insertByName(const OUString& sItem , if (pCache->hasItem(m_eType, sItem)) throw css::container::ElementExistException(OUString(), static_cast< css::container::XNameContainer* >(this)); pCache->setItem(m_eType, sItem, aItem); - - aLock.clear(); // <- SAFE ---------------------------------- } @@ -184,15 +182,13 @@ void SAL_CALL BaseContainer::removeByName(const OUString& sItem) impl_loadOnDemand(); // SAFE -> ---------------------------------- - ::osl::ResettableMutexGuard aLock(m_aLock); + osl::MutexGuard aLock(m_aLock); // create write copy of used cache on demand ... impl_initFlushMode(); FilterCache* pCache = impl_getWorkingCache(); pCache->removeItem(m_eType, sItem); // throw exceptions automatically - - aLock.clear(); // <- SAFE ---------------------------------- } @@ -218,7 +214,7 @@ void SAL_CALL BaseContainer::replaceByName(const OUString& sItem , impl_loadOnDemand(); // SAFE -> ---------------------------------- - ::osl::ResettableMutexGuard aLock(m_aLock); + osl::MutexGuard aLock(m_aLock); // create write copy of used cache on demand ... impl_initFlushMode(); @@ -227,8 +223,6 @@ void SAL_CALL BaseContainer::replaceByName(const OUString& sItem , if (!pCache->hasItem(m_eType, sItem)) throw css::container::NoSuchElementException(OUString(), static_cast< css::container::XNameContainer* >(this)); pCache->setItem(m_eType, sItem, aItem); - - aLock.clear(); // <- SAFE ---------------------------------- } @@ -244,7 +238,7 @@ css::uno::Any SAL_CALL BaseContainer::getByName(const OUString& sItem) impl_loadOnDemand(); // SAFE -> - ::osl::ResettableMutexGuard aLock(m_aLock); + osl::MutexGuard aLock(m_aLock); CacheItem aItem; try @@ -277,7 +271,7 @@ css::uno::Sequence< OUString > SAL_CALL BaseContainer::getElementNames() impl_loadOnDemand(); // SAFE -> - ::osl::ResettableMutexGuard aLock(m_aLock); + osl::MutexGuard aLock(m_aLock); try { @@ -304,7 +298,7 @@ sal_Bool SAL_CALL BaseContainer::hasByName(const OUString& sItem) impl_loadOnDemand(); // SAFE -> - ::osl::ResettableMutexGuard aLock(m_aLock); + osl::MutexGuard aLock(m_aLock); try { @@ -338,7 +332,7 @@ sal_Bool SAL_CALL BaseContainer::hasElements() impl_loadOnDemand(); // SAFE -> - ::osl::ResettableMutexGuard aLock(m_aLock); + osl::MutexGuard aLock(m_aLock); try { @@ -373,7 +367,7 @@ css::uno::Reference< css::container::XEnumeration > SAL_CALL BaseContainer::crea impl_loadOnDemand(); // SAFE -> - ::osl::ResettableMutexGuard aLock(m_aLock); + osl::MutexGuard aLock(m_aLock); try { @@ -414,7 +408,7 @@ css::uno::Reference< css::container::XEnumeration > SAL_CALL BaseContainer::crea void SAL_CALL BaseContainer::flush() { // SAFE -> - ::osl::ResettableMutexGuard aLock(m_aLock); + osl::ClearableMutexGuard aLock(m_aLock); if (!m_pFlushCache) throw css::lang::WrappedTargetRuntimeException( diff --git a/filter/source/config/cache/cacheupdatelistener.cxx b/filter/source/config/cache/cacheupdatelistener.cxx index e380407eda3a..6625d4ee9286 100644 --- a/filter/source/config/cache/cacheupdatelistener.cxx +++ b/filter/source/config/cache/cacheupdatelistener.cxx @@ -50,7 +50,7 @@ CacheUpdateListener::~CacheUpdateListener() void CacheUpdateListener::startListening() { // SAFE -> - ::osl::ResettableMutexGuard aLock(m_aLock); + osl::ClearableMutexGuard aLock(m_aLock); css::uno::Reference< css::util::XChangesNotifier > xNotifier(m_xConfig, css::uno::UNO_QUERY); aLock.clear(); // <- SAFE @@ -66,7 +66,7 @@ void CacheUpdateListener::startListening() void CacheUpdateListener::stopListening() { // SAFE -> - ::osl::ResettableMutexGuard aLock(m_aLock); + osl::ClearableMutexGuard aLock(m_aLock); css::uno::Reference< css::util::XChangesNotifier > xNotifier(m_xConfig, css::uno::UNO_QUERY); aLock.clear(); // <- SAFE @@ -82,7 +82,7 @@ void CacheUpdateListener::stopListening() void SAL_CALL CacheUpdateListener::changesOccurred(const css::util::ChangesEvent& aEvent) { // SAFE -> - ::osl::ResettableMutexGuard aLock(m_aLock); + osl::ClearableMutexGuard aLock(m_aLock); // disposed ? if ( ! m_xConfig.is()) @@ -176,10 +176,9 @@ void SAL_CALL CacheUpdateListener::changesOccurred(const css::util::ChangesEven void SAL_CALL CacheUpdateListener::disposing(const css::lang::EventObject& aEvent) { // SAFE -> - ::osl::ResettableMutexGuard aLock(m_aLock); + osl::MutexGuard aLock(m_aLock); if (aEvent.Source == m_xConfig) m_xConfig.clear(); - aLock.clear(); // <- SAFE } diff --git a/filter/source/config/cache/contenthandlerfactory.cxx b/filter/source/config/cache/contenthandlerfactory.cxx index ae7b03c7cec9..11ad89a99474 100644 --- a/filter/source/config/cache/contenthandlerfactory.cxx +++ b/filter/source/config/cache/contenthandlerfactory.cxx @@ -57,7 +57,7 @@ css::uno::Reference< css::uno::XInterface > SAL_CALL ContentHandlerFactory::crea css::uno::Reference< css::uno::XInterface > xHandler; // SAFE -> - ::osl::ResettableMutexGuard aLock(m_aLock); + osl::MutexGuard aLock(m_aLock); auto & cache = TheFilterCache::get(); diff --git a/filter/source/config/cache/filtercache.cxx b/filter/source/config/cache/filtercache.cxx index 5a1fba1ed651..f717f109a26f 100644 --- a/filter/source/config/cache/filtercache.cxx +++ b/filter/source/config/cache/filtercache.cxx @@ -121,7 +121,7 @@ FilterCache::~FilterCache() std::unique_ptr<FilterCache> FilterCache::clone() const { // SAFE -> ---------------------------------- - ::osl::ResettableMutexGuard aLock(m_aLock); + osl::MutexGuard aLock(m_aLock); auto pClone = std::make_unique<FilterCache>(); @@ -153,7 +153,7 @@ std::unique_ptr<FilterCache> FilterCache::clone() const void FilterCache::takeOver(const FilterCache& rClone) { // SAFE -> ---------------------------------- - ::osl::ResettableMutexGuard aLock(m_aLock); + osl::MutexGuard aLock(m_aLock); // a) // Don't copy the configuration access points here! @@ -201,7 +201,7 @@ void FilterCache::takeOver(const FilterCache& rClone) void FilterCache::load(EFillState eRequired) { // SAFE -> ---------------------------------- - ::osl::ResettableMutexGuard aLock(m_aLock); + osl::MutexGuard aLock(m_aLock); // check if required fill state is already reached ... // There is nothing to do then. @@ -240,7 +240,7 @@ void FilterCache::load(EFillState eRequired) bool FilterCache::isFillState(FilterCache::EFillState eState) const { // SAFE -> - ::osl::ResettableMutexGuard aLock(m_aLock); + osl::MutexGuard aLock(m_aLock); return ((m_eFillState & eState) == eState); // <- SAFE } @@ -251,7 +251,7 @@ std::vector<OUString> FilterCache::getMatchingItemsByProps( EItemType eTyp const CacheItem& lEProps) const { // SAFE -> - ::osl::ResettableMutexGuard aLock(m_aLock); + osl::MutexGuard aLock(m_aLock); // search for right list // An exception is thrown - "eType" is unknown. @@ -281,7 +281,7 @@ std::vector<OUString> FilterCache::getMatchingItemsByProps( EItemType eTyp bool FilterCache::hasItems(EItemType eType) const { // SAFE -> - ::osl::ResettableMutexGuard aLock(m_aLock); + osl::MutexGuard aLock(m_aLock); // search for right list // An exception is thrown - "eType" is unknown. @@ -296,7 +296,7 @@ bool FilterCache::hasItems(EItemType eType) const std::vector<OUString> FilterCache::getItemNames(EItemType eType) const { // SAFE -> - ::osl::ResettableMutexGuard aLock(m_aLock); + osl::MutexGuard aLock(m_aLock); // search for right list // An exception is thrown - "eType" is unknown. @@ -317,7 +317,7 @@ bool FilterCache::hasItem( EItemType eType, const OUString& sItem) { // SAFE -> - ::osl::ResettableMutexGuard aLock(m_aLock); + osl::MutexGuard aLock(m_aLock); // search for right list // An exception is thrown - "eType" is unknown. @@ -349,7 +349,7 @@ CacheItem FilterCache::getItem( EItemType eType, const OUString& sItem) { // SAFE -> - ::osl::ResettableMutexGuard aLock(m_aLock); + osl::MutexGuard aLock(m_aLock); // search for right list // An exception is thrown if "eType" is unknown. @@ -399,7 +399,7 @@ void FilterCache::removeItem( EItemType eType, const OUString& sItem) { // SAFE -> - ::osl::ResettableMutexGuard aLock(m_aLock); + osl::MutexGuard aLock(m_aLock); // search for right list // An exception is thrown - "eType" is unknown. @@ -420,7 +420,7 @@ void FilterCache::setItem( EItemType eType , const CacheItem& aValue) { // SAFE -> - ::osl::ResettableMutexGuard aLock(m_aLock); + osl::MutexGuard aLock(m_aLock); // search for right list // An exception is thrown - "eType" is unknown. @@ -447,7 +447,7 @@ void FilterCache::refreshItem( EItemType eType, const OUString& sItem) { // SAFE -> - ::osl::ResettableMutexGuard aLock(m_aLock); + osl::MutexGuard aLock(m_aLock); impl_loadItemOnDemand(eType, sItem); } @@ -457,7 +457,7 @@ void FilterCache::addStatePropsToItem( EItemType eType, CacheItem& rItem) { // SAFE -> - ::osl::ResettableMutexGuard aLock(m_aLock); + osl::MutexGuard aLock(m_aLock); // Note: Opening of the configuration layer throws some exceptions // if it failed. So we mustn't check any reference here... @@ -562,7 +562,7 @@ void FilterCache::removeStatePropsFromItem(CacheItem& rItem) void FilterCache::flush() { // SAFE -> - ::osl::ResettableMutexGuard aLock(m_aLock); + osl::MutexGuard aLock(m_aLock); // renew all dependencies and optimizations impl_validateAndOptimize(); @@ -664,7 +664,7 @@ void FilterCache::detectFlatForURL(const css::util::URL& aURL , sExtension = sExtension.toAsciiLowerCase(); // SAFE -> ---------------------------------- - ::osl::ResettableMutexGuard aLock(m_aLock); + osl::MutexGuard aLock(m_aLock); // i) Step over all well known URL pattern @@ -707,14 +707,13 @@ void FilterCache::detectFlatForURL(const css::util::URL& aURL , } } - aLock.clear(); // <- SAFE ---------------------------------- } const CacheItemList& FilterCache::impl_getItemList(EItemType eType) const { // SAFE -> ---------------------------------- - ::osl::ResettableMutexGuard aLock(m_aLock); + osl::MutexGuard aLock(m_aLock); switch(eType) { @@ -733,7 +732,7 @@ const CacheItemList& FilterCache::impl_getItemList(EItemType eType) const CacheItemList& FilterCache::impl_getItemList(EItemType eType) { // SAFE -> ---------------------------------- - ::osl::ResettableMutexGuard aLock(m_aLock); + osl::MutexGuard aLock(m_aLock); switch(eType) { @@ -751,7 +750,7 @@ CacheItemList& FilterCache::impl_getItemList(EItemType eType) css::uno::Reference< css::uno::XInterface > FilterCache::impl_openConfig(EConfigProvider eProvider) { - ::osl::ResettableMutexGuard aLock(m_aLock); + osl::MutexGuard aLock(m_aLock); OUString sPath ; css::uno::Reference< css::uno::XInterface >* pConfig = nullptr; @@ -877,7 +876,7 @@ css::uno::Reference< css::uno::XInterface > FilterCache::impl_createConfigAccess bool bLocalesMode) { // SAFE -> - ::osl::ResettableMutexGuard aLock(m_aLock); + osl::MutexGuard aLock(m_aLock); css::uno::Reference< css::uno::XInterface > xCfg; @@ -937,7 +936,7 @@ css::uno::Reference< css::uno::XInterface > FilterCache::impl_createConfigAccess void FilterCache::impl_validateAndOptimize() { // SAFE -> - ::osl::ResettableMutexGuard aLock(m_aLock); + osl::MutexGuard aLock(m_aLock); // First check if any filter or type could be read // from the underlying configuration! @@ -1254,7 +1253,7 @@ FilterCache::EItemFlushState FilterCache::impl_specifyFlushOperation(const css:: void FilterCache::impl_load(EFillState eRequiredState) { // SAFE -> - ::osl::ResettableMutexGuard aLock(m_aLock); + osl::MutexGuard aLock(m_aLock); // Attention: Detect services are part of the standard set! // So there is no need to handle it separately. @@ -1467,7 +1466,7 @@ void FilterCache::impl_readPatchUINames(const css::uno::Reference< css::containe { // SAFE -> ---------------------------------- - ::osl::ResettableMutexGuard aLock(m_aLock); + osl::ClearableMutexGuard aLock(m_aLock); OUString sActLocale = m_sActLocale ; aLock.clear(); // <- SAFE ---------------------------------- @@ -2203,14 +2202,15 @@ bool FilterCache::impl_isModuleInstalled(const OUString& sModule) css::uno::Reference< css::container::XNameAccess > xCfg; // SAFE -> - ::osl::ResettableMutexGuard aLock(m_aLock); - if (! m_xModuleCfg.is()) { - m_xModuleCfg = officecfg::Setup::Office::Factories::get(); - } + osl::MutexGuard aLock(m_aLock); + if (!m_xModuleCfg.is()) + { + m_xModuleCfg = officecfg::Setup::Office::Factories::get(); + } - xCfg = m_xModuleCfg; - aLock.clear(); + xCfg = m_xModuleCfg; + } // <- SAFE if (xCfg.is()) diff --git a/filter/source/config/cache/filterfactory.cxx b/filter/source/config/cache/filterfactory.cxx index 8e559f2de666..743131a75313 100644 --- a/filter/source/config/cache/filterfactory.cxx +++ b/filter/source/config/cache/filterfactory.cxx @@ -74,7 +74,7 @@ css::uno::Reference< css::uno::XInterface > SAL_CALL FilterFactory::createInstan const css::uno::Sequence< css::uno::Any >& lArguments) { // SAFE -> - ::osl::ResettableMutexGuard aLock(m_aLock); + osl::MutexGuard aLock(m_aLock); auto & cache = TheFilterCache::get(); @@ -164,11 +164,12 @@ css::uno::Reference< css::container::XEnumeration > SAL_CALL FilterFactory::crea if (lTokens.valid()) { // SAFE -> ---------------------- - ::osl::ResettableMutexGuard aLock(m_aLock); - // May be not all filters was loaded ... - // But we need it now! - impl_loadOnDemand(); - aLock.clear(); + { + osl::MutexGuard aLock(m_aLock); + // May be not all filters was loaded ... + // But we need it now! + impl_loadOnDemand(); + } // <- SAFE ---------------------- if (lTokens.find(QUERY_IDENTIFIER_GETPREFERREDFILTERFORTYPE) != lTokens.end()) @@ -251,7 +252,7 @@ std::vector<OUString> FilterFactory::impl_queryMatchByDocumentService(const Quer nEFlags = pIt->second.toInt32(); // SAFE -> ---------------------- - ::osl::ResettableMutexGuard aLock(m_aLock); + osl::ClearableMutexGuard aLock(m_aLock); // search suitable filters FilterCache* pCache = impl_getWorkingCache(); @@ -406,7 +407,7 @@ std::vector<OUString> FilterFactory::impl_getSortedFilterList(const QueryTokeniz std::vector<OUString> FilterFactory::impl_getListOfInstalledModules() const { // SAFE -> ---------------------- - ::osl::ResettableMutexGuard aLock(m_aLock); + osl::ClearableMutexGuard aLock(m_aLock); css::uno::Reference< css::uno::XComponentContext > xContext = m_xContext; aLock.clear(); // <- SAFE ---------------------- @@ -428,7 +429,7 @@ std::vector<OUString> FilterFactory::impl_getSortedFilterListForModule(const OUS lIProps[PROPNAME_DOCUMENTSERVICE] <<= sModule; // SAFE -> ---------------------- - ::osl::ResettableMutexGuard aLock(m_aLock); + osl::ClearableMutexGuard aLock(m_aLock); FilterCache* pCache = impl_getWorkingCache(); std::vector<OUString> lOtherFilters = pCache->getMatchingItemsByProps(FilterCache::E_FILTER, lIProps); aLock.clear(); @@ -469,7 +470,7 @@ std::vector<OUString> FilterFactory::impl_getSortedFilterListForModule(const OUS std::vector<OUString> FilterFactory::impl_readSortedFilterListFromConfig(const OUString& sModule) const { // SAFE -> ---------------------- - ::osl::ResettableMutexGuard aLock(m_aLock); + osl::ClearableMutexGuard aLock(m_aLock); css::uno::Reference< css::uno::XComponentContext > xContext = m_xContext; aLock.clear(); // <- SAFE ---------------------- diff --git a/filter/source/config/cache/frameloaderfactory.cxx b/filter/source/config/cache/frameloaderfactory.cxx index abf51d859baf..14b09a5fdb5a 100644 --- a/filter/source/config/cache/frameloaderfactory.cxx +++ b/filter/source/config/cache/frameloaderfactory.cxx @@ -54,7 +54,7 @@ css::uno::Reference< css::uno::XInterface > SAL_CALL FrameLoaderFactory::createI const css::uno::Sequence< css::uno::Any >& lArguments) { // SAFE -> - ::osl::ResettableMutexGuard aLock(m_aLock); + osl::MutexGuard aLock(m_aLock); auto & cache = TheFilterCache::get(); diff --git a/filter/source/config/cache/typedetection.cxx b/filter/source/config/cache/typedetection.cxx index 278f53eea11a..738f09a671c8 100644 --- a/filter/source/config/cache/typedetection.cxx +++ b/filter/source/config/cache/typedetection.cxx @@ -74,7 +74,7 @@ OUString SAL_CALL TypeDetection::queryTypeByURL(const OUString& sURL) OUString sType; // SAFE -> - ::osl::ResettableMutexGuard aLock(m_aLock); + osl::MutexGuard aLock(m_aLock); css::util::URL aURL; aURL.Complete = sURL; @@ -379,7 +379,7 @@ OUString SAL_CALL TypeDetection::queryTypeByDescriptor(css::uno::Sequence< css:: try { // SAFE -> ---------------------------------- - ::osl::ResettableMutexGuard aLock(m_aLock); + osl::ClearableMutexGuard aLock(m_aLock); // parse given URL to split it into e.g. main and jump marks ... sURL = stlDescriptor.getUnpackedValueOrDefault(utl::MediaDescriptor::PROP_URL(), OUString()); @@ -549,7 +549,7 @@ void TypeDetection::impl_checkResultsAndAddBestFilter(utl::MediaDescriptor& rDes try { // SAFE -> - ::osl::ResettableMutexGuard aLock(m_aLock); + osl::ClearableMutexGuard aLock(m_aLock); CacheItem aType = cache.getItem(FilterCache::E_TYPE, sType); aType[PROPNAME_PREFERREDFILTER] >>= sFilter; @@ -644,9 +644,8 @@ bool TypeDetection::impl_getPreselectionForType( try { // SAFE -> -------------------------- - ::osl::ResettableMutexGuard aLock(m_aLock); + osl::MutexGuard aLock(m_aLock); aType = TheFilterCache::get().getItem(FilterCache::E_TYPE, sType); - aLock.clear(); // <- SAFE -------------------------- } catch(const css::container::NoSuchElementException&) @@ -731,7 +730,7 @@ void TypeDetection::impl_getPreselectionForDocumentService( try { // SAFE -> -------------------------- - ::osl::ResettableMutexGuard aLock(m_aLock); + osl::MutexGuard aLock(m_aLock); // Attention: For executing next lines of code, We must be sure that // all filters already loaded :-( @@ -742,8 +741,6 @@ void TypeDetection::impl_getPreselectionForDocumentService( CacheItem lIProps; lIProps[PROPNAME_DOCUMENTSERVICE] <<= sPreSelDocumentService; lFilters = cache.getMatchingItemsByProps(FilterCache::E_FILTER, lIProps); - - aLock.clear(); // <- SAFE -------------------------- } catch (const css::container::NoSuchElementException&) @@ -905,7 +902,7 @@ OUString TypeDetection::impl_detectTypeFlatAndDeep( utl::MediaDescriptor& r try { // SAFE -> ---------------------------------- - ::osl::ResettableMutexGuard aLock(m_aLock); + osl::ClearableMutexGuard aLock(m_aLock); CacheItem aType = TheFilterCache::get().getItem(FilterCache::E_TYPE, sFlatType); aLock.clear(); @@ -986,9 +983,10 @@ OUString TypeDetection::impl_askDetectService(const OUString& sDet css::uno::Reference< css::uno::XComponentContext > xContext; // SAFE -> - ::osl::ResettableMutexGuard aLock(m_aLock); - xContext = m_xContext; - aLock.clear(); + { + osl::MutexGuard aLock(m_aLock); + xContext = m_xContext; + } // <- SAFE try @@ -1158,13 +1156,14 @@ bool TypeDetection::impl_validateAndSetTypeOnDescriptor( utl::MediaDescript const OUString& sType ) { // SAFE -> - ::osl::ResettableMutexGuard aLock(m_aLock); - if (TheFilterCache::get().hasItem(FilterCache::E_TYPE, sType)) { - rDescriptor[utl::MediaDescriptor::PROP_TYPENAME()] <<= sType; - return true; + osl::MutexGuard aLock(m_aLock); + if (TheFilterCache::get().hasItem(FilterCache::E_TYPE, sType)) + { + rDescriptor[utl::MediaDescriptor::PROP_TYPENAME()] <<= sType; + return true; + } } - aLock.clear(); // <- SAFE // remove all related information from the descriptor @@ -1179,7 +1178,7 @@ bool TypeDetection::impl_validateAndSetFilterOnDescriptor( utl::MediaDescri try { // SAFE -> - ::osl::ResettableMutexGuard aLock(m_aLock); + osl::ClearableMutexGuard aLock(m_aLock); auto & cache = TheFilterCache::get(); CacheItem aFilter = cache.getItem(FilterCache::E_FILTER, sFilter); diff --git a/forms/source/component/DatabaseForm.cxx b/forms/source/component/DatabaseForm.cxx index 39bbcbf411de..30795285a12d 100644 --- a/forms/source/component/DatabaseForm.cxx +++ b/forms/source/component/DatabaseForm.cxx @@ -1877,7 +1877,7 @@ Any ODatabaseForm::getPropertyDefaultByHandle( sal_Int32 nHandle ) const void SAL_CALL ODatabaseForm::reset() { - ::osl::ResettableMutexGuard aGuard(m_aMutex); + osl::ClearableMutexGuard aGuard(m_aMutex); if (isLoaded()) { @@ -2304,7 +2304,7 @@ void ODatabaseForm::_propertyChanged(const PropertyChangeEvent& evt) void SAL_CALL ODatabaseForm::setParent(const css::uno::Reference<css::uno::XInterface>& Parent) { // SYNCHRONIZED -----> - ::osl::ResettableMutexGuard aGuard(m_aMutex); + osl::ClearableMutexGuard aGuard(m_aMutex); Reference<XForm> xParentForm(getParent(), UNO_QUERY); if (xParentForm.is()) @@ -2364,7 +2364,7 @@ void SAL_CALL ODatabaseForm::setParent(const css::uno::Reference<css::uno::XInte sal_Bool SAL_CALL ODatabaseForm::getGroupControl() { - ::osl::ResettableMutexGuard aGuard(m_aMutex); + osl::MutexGuard aGuard(m_aMutex); // Should controls be combined into a TabOrder group? if (m_aCycle.hasValue()) @@ -2383,7 +2383,7 @@ sal_Bool SAL_CALL ODatabaseForm::getGroupControl() void SAL_CALL ODatabaseForm::setControlModels(const Sequence<Reference<XControlModel> >& rControls) { - ::osl::ResettableMutexGuard aGuard(m_aMutex); + osl::MutexGuard aGuard(m_aMutex); // Set TabIndex in the order of the sequence sal_Int32 nCount = getCount(); @@ -2968,7 +2968,7 @@ void SAL_CALL ODatabaseForm::cursorMoved(const EventObject& /*event*/) { // reload the subform with the new parameters of the parent // do this handling delayed to provide of execute too many SQL Statements - ::osl::ResettableMutexGuard aGuard(m_aMutex); + osl::MutexGuard aGuard(m_aMutex); DBG_ASSERT( m_pLoadTimer, "ODatabaseForm::cursorMoved: how can this happen?!" ); if ( !m_pLoadTimer ) @@ -3158,7 +3158,7 @@ sal_Bool SAL_CALL ODatabaseForm::approveRowSetChange(const EventObject& event) void SAL_CALL ODatabaseForm::addRowSetApproveListener(const Reference<XRowSetApproveListener>& _rListener) { - ::osl::ResettableMutexGuard aGuard(m_aMutex); + osl::MutexGuard aGuard(m_aMutex); m_aRowSetApproveListeners.addInterface(_rListener); // do we have to multiplex ? @@ -3176,7 +3176,7 @@ void SAL_CALL ODatabaseForm::addRowSetApproveListener(const Reference<XRowSetApp void SAL_CALL ODatabaseForm::removeRowSetApproveListener(const Reference<XRowSetApproveListener>& _rListener) { - ::osl::ResettableMutexGuard aGuard(m_aMutex); + osl::MutexGuard aGuard(m_aMutex); // do we have to remove the multiplex ? m_aRowSetApproveListeners.removeInterface(_rListener); if ( m_aRowSetApproveListeners.getLength() == 0 ) @@ -3244,7 +3244,7 @@ void SAL_CALL ODatabaseForm::executeWithCompletion( const Reference< XInteractio void SAL_CALL ODatabaseForm::execute() { - ::osl::ResettableMutexGuard aGuard(m_aMutex); + osl::ClearableMutexGuard aGuard(m_aMutex); // if somebody calls an execute and we're not loaded we reroute this call to our load method. // the difference between execute and load is, that we position on the first row in case of load diff --git a/forms/source/component/FormComponent.cxx b/forms/source/component/FormComponent.cxx index 4ab830b7f5a4..0832a64031bf 100644 --- a/forms/source/component/FormComponent.cxx +++ b/forms/source/component/FormComponent.cxx @@ -1344,7 +1344,7 @@ void OBoundControlModel::disposing() { OControlModel::disposing(); - ::osl::ClearableMutexGuard aGuard(m_aMutex); + osl::MutexGuard aGuard(m_aMutex); if ( m_pAggPropMultiplexer ) m_pAggPropMultiplexer->dispose(); @@ -2697,7 +2697,7 @@ void OBoundControlModel::disconnectValidator( ) void SAL_CALL OBoundControlModel::setValidator( const Reference< XValidator >& _rxValidator ) { - ::osl::ClearableMutexGuard aGuard( m_aMutex ); + osl::MutexGuard aGuard( m_aMutex ); OSL_PRECOND( m_bSupportsValidation, "OBoundControlModel::setValidator: How did you reach this method?" ); // the interface for this method should not have been exposed if we do not // support validation @@ -2733,7 +2733,7 @@ Reference< XValidator > SAL_CALL OBoundControlModel::getValidator( ) void SAL_CALL OBoundControlModel::validityConstraintChanged( const EventObject& /*Source*/ ) { - ::osl::ClearableMutexGuard aGuard( m_aMutex ); + osl::MutexGuard aGuard( m_aMutex ); OSL_PRECOND( m_bSupportsValidation, "OBoundControlModel::validityConstraintChanged: How did you reach this method?" ); // the interface for this method should not have been exposed if we do not // support validation diff --git a/forms/source/component/ListBox.cxx b/forms/source/component/ListBox.cxx index fcf16abe66b4..9194f846692f 100644 --- a/forms/source/component/ListBox.cxx +++ b/forms/source/component/ListBox.cxx @@ -1907,7 +1907,7 @@ namespace frm m_aItemListeners.notifyEach( &XItemListener::itemStateChanged, _rEvent ); // and do the handling for the ChangeListeners - ::osl::ClearableMutexGuard aGuard(m_aMutex); + osl::MutexGuard aGuard(m_aMutex); if ( m_aChangeIdle.IsActive() ) { Reference<XPropertySet> xSet(getModel(), UNO_QUERY); diff --git a/fpicker/source/win32/VistaFilePickerImpl.cxx b/fpicker/source/win32/VistaFilePickerImpl.cxx index 76e1062c7cfd..a2cc6d01468b 100644 --- a/fpicker/source/win32/VistaFilePickerImpl.cxx +++ b/fpicker/source/win32/VistaFilePickerImpl.cxx @@ -202,7 +202,7 @@ VistaFilePickerImpl::~VistaFilePickerImpl() void VistaFilePickerImpl::before() { // SYNCHRONIZED-> - ::osl::ResettableMutexGuard aLock(m_aMutex); + osl::MutexGuard aLock(m_aMutex); // TRICKY .-) // osl::Thread class initializes COm already in MTA mode because it's needed @@ -336,7 +336,7 @@ void VistaFilePickerImpl::impl_sta_addFilePickerListener(const RequestRef& rRequ return; // SYNCHRONIZED-> - ::osl::ResettableMutexGuard aLock(m_aMutex); + osl::ClearableMutexGuard aLock(m_aMutex); TFileDialogEvents iHandler = m_iEventHandler; aLock.clear(); // <- SYNCHRONIZED @@ -355,7 +355,7 @@ void VistaFilePickerImpl::impl_sta_removeFilePickerListener(const RequestRef& rR return; // SYNCHRONIZED-> - ::osl::ResettableMutexGuard aLock(m_aMutex); + osl::ClearableMutexGuard aLock(m_aMutex); TFileDialogEvents iHandler = m_iEventHandler; aLock.clear(); // <- SYNCHRONIZED @@ -372,7 +372,7 @@ void VistaFilePickerImpl::impl_sta_appendFilter(const RequestRef& rRequest) const OUString sFilter = rRequest->getArgumentOrDefault(PROP_FILTER_VALUE, OUString()); // SYNCHRONIZED-> - ::osl::ResettableMutexGuard aLock(m_aMutex); + osl::MutexGuard aLock(m_aMutex); m_lFilters.addFilter(sTitle, sFilter); } @@ -384,7 +384,7 @@ void VistaFilePickerImpl::impl_sta_appendFilterGroup(const RequestRef& rRequest) rRequest->getArgumentOrDefault(PROP_FILTER_GROUP, css::uno::Sequence< css::beans::StringPair >()); // SYNCHRONIZED-> - ::osl::ResettableMutexGuard aLock(m_aMutex); + osl::MutexGuard aLock(m_aMutex); if ( m_lFilters.numFilter() > 0 && aFilterGroup.getLength() > 0 ) m_lFilters.addFilter( STRING_SEPARATOR, "", true ); @@ -404,7 +404,7 @@ void VistaFilePickerImpl::impl_sta_setCurrentFilter(const RequestRef& rRequest) const OUString sTitle = rRequest->getArgumentOrDefault(PROP_FILTER_TITLE, OUString()); // SYNCHRONIZED-> - ::osl::ResettableMutexGuard aLock(m_aMutex); + osl::MutexGuard aLock(m_aMutex); m_lFilters.setCurrentFilter(sTitle); } @@ -422,7 +422,7 @@ void VistaFilePickerImpl::impl_sta_getCurrentFilter(const RequestRef& rRequest) return; // SYNCHRONIZED-> - ::osl::ResettableMutexGuard aLock(m_aMutex); + osl::MutexGuard aLock(m_aMutex); OUString sTitle; ::sal_Int32 nRealIndex = nIndex-1; // COM dialog base on 1 ... filter container on 0 .-) @@ -436,8 +436,6 @@ void VistaFilePickerImpl::impl_sta_getCurrentFilter(const RequestRef& rRequest) sTitle = m_lFilters.getCurrentFilter(); rRequest->setArgument(PROP_FILTER_TITLE, sTitle); } - - aLock.clear(); // <- SYNCHRONIZED } @@ -445,7 +443,7 @@ void VistaFilePickerImpl::impl_sta_getCurrentFilter(const RequestRef& rRequest) void VistaFilePickerImpl::impl_sta_CreateDialog(const RequestRef& rRequest, PickerDialog eType, DWORD nOrFlags) { // SYNCHRONIZED-> - ::osl::ResettableMutexGuard aLock(m_aMutex); + osl::ClearableMutexGuard aLock(m_aMutex); TFileDialog iDialog; @@ -710,7 +708,7 @@ void VistaFilePickerImpl::impl_sta_SetMultiSelectionMode(const RequestRef& rRequ const bool bMultiSelection = rRequest->getArgumentOrDefault(PROP_MULTISELECTION_MODE, true); // SYNCHRONIZED-> - ::osl::ResettableMutexGuard aLock(m_aMutex); + osl::ClearableMutexGuard aLock(m_aMutex); TFileDialog iDialog = impl_getBaseDialogInterface(); aLock.clear(); // <- SYNCHRONIZED @@ -732,7 +730,7 @@ void VistaFilePickerImpl::impl_sta_SetTitle(const RequestRef& rRequest) OUString sTitle = rRequest->getArgumentOrDefault(PROP_TITLE, OUString()); // SYNCHRONIZED-> - ::osl::ResettableMutexGuard aLock(m_aMutex); + osl::ClearableMutexGuard aLock(m_aMutex); TFileDialog iDialog = impl_getBaseDialogInterface(); aLock.clear(); // <- SYNCHRONIZED @@ -746,7 +744,7 @@ void VistaFilePickerImpl::impl_sta_SetFileName(const RequestRef& rRequest) OUString sFileName = rRequest->getArgumentOrDefault(PROP_FILENAME, OUString()); // SYNCHRONIZED-> - ::osl::ResettableMutexGuard aLock(m_aMutex); + osl::ClearableMutexGuard aLock(m_aMutex); TFileDialog iDialog = impl_getBaseDialogInterface(); aLock.clear(); // <- SYNCHRONIZED @@ -771,7 +769,7 @@ void VistaFilePickerImpl::impl_sta_SetDirectory(const RequestRef& rRequest) } // SYNCHRONIZED-> - ::osl::ResettableMutexGuard aLock(m_aMutex); + osl::ClearableMutexGuard aLock(m_aMutex); TFileDialog iDialog = impl_getBaseDialogInterface(); aLock.clear(); // <- SYNCHRONIZED @@ -832,7 +830,7 @@ void VistaFilePickerImpl::impl_sta_SetDefaultName(const RequestRef& rRequest) void VistaFilePickerImpl::impl_sta_setFiltersOnDialog() { // SYNCHRONIZED-> - ::osl::ResettableMutexGuard aLock(m_aMutex); + osl::ClearableMutexGuard aLock(m_aMutex); std::vector<OUString> vStrings; // to hold the adjusted filter names, pointers to which will be // stored in lFilters @@ -873,7 +871,7 @@ void VistaFilePickerImpl::impl_sta_setFiltersOnDialog() void VistaFilePickerImpl::impl_sta_getSelectedFiles(const RequestRef& rRequest) { // SYNCHRONIZED-> - ::osl::ResettableMutexGuard aLock(m_aMutex); + osl::ClearableMutexGuard aLock(m_aMutex); TFileOpenDialog iOpen = m_iDialogOpen; TFileSaveDialog iSave = m_iDialogSave; @@ -1067,7 +1065,7 @@ TFileDialog VistaFilePickerImpl::impl_getBaseDialogInterface() TFileDialog iDialog; // SYNCHRONIZED-> - ::osl::ResettableMutexGuard aLock(m_aMutex); + osl::MutexGuard aLock(m_aMutex); if (m_iDialogOpen.is()) m_iDialogOpen.query(&iDialog); @@ -1085,7 +1083,7 @@ TFileDialogCustomize VistaFilePickerImpl::impl_getCustomizeInterface() TFileDialogCustomize iCustom; // SYNCHRONIZED-> - ::osl::ResettableMutexGuard aLock(m_aMutex); + osl::MutexGuard aLock(m_aMutex); if (m_iDialogOpen.is()) m_iDialogOpen.query(&iCustom); @@ -1298,7 +1296,7 @@ void VistaFilePickerImpl::impl_SetDefaultExtension( const OUString& currentFilte void VistaFilePickerImpl::onAutoExtensionChanged (bool bChecked) { // SYNCHRONIZED-> - ::osl::ResettableMutexGuard aLock(m_aMutex); + osl::ClearableMutexGuard aLock(m_aMutex); const OUString sFilter = m_lFilters.getCurrentFilter (); OUString sExt ; diff --git a/fpicker/source/win32/asyncrequests.cxx b/fpicker/source/win32/asyncrequests.cxx index cdcfb6d630e9..86b71cf51540 100644 --- a/fpicker/source/win32/asyncrequests.cxx +++ b/fpicker/source/win32/asyncrequests.cxx @@ -75,9 +75,10 @@ AsyncRequests::AsyncRequests(const RequestHandlerRef& rHandler) AsyncRequests::~AsyncRequests() { // SYNCHRONIZED -> - ::osl::ResettableMutexGuard aLock(m_aMutex); - m_bFinish = true; - aLock.clear(); + { + osl::MutexGuard aLock(m_aMutex); + m_bFinish = true; + } // <- SYNCHRONIZED // The static AsyncRequests aNotify in VistaFilePickerEventHandler::impl_sendEvent @@ -106,9 +107,10 @@ void AsyncRequests::triggerJobExecution() void AsyncRequests::triggerRequestProcessMessages (const RequestRef& rRequest) { // SYNCHRONIZED -> - ::osl::ResettableMutexGuard aLock(m_aMutex); - m_lRequests.push(rRequest); - aLock.clear(); + { + osl::MutexGuard aLock(m_aMutex); + m_lRequests.push(rRequest); + } // <- SYNCHRONIZED rRequest->waitProcessMessages(); @@ -117,9 +119,10 @@ void AsyncRequests::triggerRequestProcessMessages (const RequestRef& rRequest) void AsyncRequests::triggerRequestBlocked(const RequestRef& rRequest) { // SYNCHRONIZED -> - ::osl::ResettableMutexGuard aLock(m_aMutex); - m_lRequests.push(rRequest); - aLock.clear(); + { + osl::MutexGuard aLock(m_aMutex); + m_lRequests.push(rRequest); + } // <- SYNCHRONIZED triggerJobExecution(); @@ -130,9 +133,10 @@ void AsyncRequests::triggerRequestBlocked(const RequestRef& rRequest) void AsyncRequests::triggerRequestNonBlocked(const RequestRef& rRequest) { // SYNCHRONIZED -> - ::osl::ResettableMutexGuard aLock(m_aMutex); - m_lRequests.push(rRequest); - aLock.clear(); + { + osl::MutexGuard aLock(m_aMutex); + m_lRequests.push(rRequest); + } // <- SYNCHRONIZED triggerJobExecution(); @@ -141,7 +145,7 @@ void AsyncRequests::triggerRequestNonBlocked(const RequestRef& rRequest) void AsyncRequests::triggerRequestDirectly(const RequestRef& rRequest) { // SYNCHRONIZED -> - ::osl::ResettableMutexGuard aLock(m_aMutex); + osl::ClearableMutexGuard aLock(m_aMutex); RequestHandlerRef rHandler = m_rHandler; aLock.clear(); // <- SYNCHRONIZED diff --git a/framework/source/accelerators/storageholder.cxx b/framework/source/accelerators/storageholder.cxx index d6f52ffcff72..ca807eabf684 100644 --- a/framework/source/accelerators/storageholder.cxx +++ b/framework/source/accelerators/storageholder.cxx @@ -208,9 +208,10 @@ void StorageHolder::commitPath(const OUString& sPath) } // SAFE -> ------------------------------ - osl::ClearableMutexGuard aReadLock(m_mutex); - xCommit.set(m_xRoot, css::uno::UNO_QUERY); - aReadLock.clear(); + { + osl::MutexGuard aReadLock(m_mutex); + xCommit.set(m_xRoot, css::uno::UNO_QUERY); + } // <- SAFE ------------------------------ if (xCommit.is()) @@ -345,25 +346,25 @@ css::uno::Reference< css::embed::XStorage > StorageHolder::getParentStorage(cons return css::uno::Reference< css::embed::XStorage >(); // SAFE -> ---------------------------------- - osl::ClearableMutexGuard aReadLock(m_mutex); - - // b) - if (c < 2) - return m_xRoot; - - // c) - OUStringBuffer sParentPath; - sal_Int32 i = 0; - for (i=0; i<c-1; ++i) { - sParentPath.append(lFolders[i]).append(PATH_SEPARATOR); - } + osl::MutexGuard aReadLock(m_mutex); - TPath2StorageInfo::const_iterator pParent = m_lStorages.find(sParentPath.makeStringAndClear()); - if (pParent != m_lStorages.end()) - return pParent->second.Storage; + // b) + if (c < 2) + return m_xRoot; - aReadLock.clear(); + // c) + OUStringBuffer sParentPath; + sal_Int32 i = 0; + for (i = 0; i < c - 1; ++i) + { + sParentPath.append(lFolders[i]).append(PATH_SEPARATOR); + } + + auto pParent = m_lStorages.find(sParentPath.makeStringAndClear()); + if (pParent != m_lStorages.end()) + return pParent->second.Storage; + } // <- SAFE ---------------------------------- // ? diff --git a/framework/source/dispatch/interceptionhelper.cxx b/framework/source/dispatch/interceptionhelper.cxx index 9a98285ec720..bca143bc92a3 100644 --- a/framework/source/dispatch/interceptionhelper.cxx +++ b/framework/source/dispatch/interceptionhelper.cxx @@ -40,40 +40,40 @@ css::uno::Reference< css::frame::XDispatch > SAL_CALL InterceptionHelper::queryD const OUString& sTargetFrameName, sal_Int32 nSearchFlags ) { + css::uno::Reference<css::frame::XDispatchProvider> xInterceptor; // SAFE { - SolarMutexClearableGuard aReadLock; + { + SolarMutexGuard aReadLock; - // a) first search an interceptor, which match to this URL by its URL pattern registration - // Note: if it return NULL - it does not mean an empty interceptor list automatically! - css::uno::Reference< css::frame::XDispatchProvider > xInterceptor; - InterceptorList::const_iterator pIt = m_lInterceptionRegs.findByPattern(aURL.Complete); - if (pIt != m_lInterceptionRegs.end()) - xInterceptor = pIt->xInterceptor; + // a) first search an interceptor, which match to this URL by its URL pattern registration + // Note: if it return NULL - it does not mean an empty interceptor list automatically! + InterceptorList::const_iterator pIt = m_lInterceptionRegs.findByPattern(aURL.Complete); + if (pIt != m_lInterceptionRegs.end()) + xInterceptor = pIt->xInterceptor; - // b) No match by registration - but a valid interceptor list. - // Find first interceptor w/o pattern, so we need to query it - if (!xInterceptor.is()) - { - for (auto const& lInterceptionReg : m_lInterceptionRegs) + // b) No match by registration - but a valid interceptor list. + // Find first interceptor w/o pattern, so we need to query it + if (!xInterceptor.is()) { - if (!lInterceptionReg.lURLPattern.getLength()) + for (auto const& lInterceptionReg : m_lInterceptionRegs) { - // no pattern -> need to ask this guy! - xInterceptor = lInterceptionReg.xInterceptor; - break; + if (!lInterceptionReg.lURLPattern.getLength()) + { + // no pattern -> need to ask this guy! + xInterceptor = lInterceptionReg.xInterceptor; + break; + } } + // if we didn't find any non-pattern interceptor, there's no-one + // registered for this command url (we already searched for matching + // patterns above) } - // if we didn't find any non-pattern interceptor, there's no-one - // registered for this command url (we already searched for matching - // patterns above) + // c) No registered interceptor => use our direct slave. + // This helper exist by design and must be valid everytimes ... + // But to be more feature proof - we should check that .-) + if (!xInterceptor.is() && m_xSlave.is()) + xInterceptor = m_xSlave; } - // c) No registered interceptor => use our direct slave. - // This helper exist by design and must be valid everytimes ... - // But to be more feature proof - we should check that .-) - if (!xInterceptor.is() && m_xSlave.is()) - xInterceptor = m_xSlave; - - aReadLock.clear(); // } SAFE css::uno::Reference< css::frame::XDispatch > xReturn; diff --git a/framework/source/fwe/helper/titlehelper.cxx b/framework/source/fwe/helper/titlehelper.cxx index cd7551882e89..c15098ed8901 100644 --- a/framework/source/fwe/helper/titlehelper.cxx +++ b/framework/source/fwe/helper/titlehelper.cxx @@ -69,7 +69,7 @@ void TitleHelper::setOwner(const css::uno::Reference< css::uno::XInterface >& xO { // SYNCHRONIZED -> { - ::osl::ResettableMutexGuard aLock(m_aMutex); + osl::MutexGuard aLock(m_aMutex); m_xOwner = xOwner; } @@ -100,7 +100,7 @@ void TitleHelper::setOwner(const css::uno::Reference< css::uno::XInterface >& xO OUString SAL_CALL TitleHelper::getTitle() { // SYNCHRONIZED -> - ::osl::ResettableMutexGuard aLock(m_aMutex); + osl::MutexGuard aLock(m_aMutex); // An external title will win always and disable all internal logic about // creating/using a title value. @@ -122,7 +122,7 @@ OUString SAL_CALL TitleHelper::getTitle() void TitleHelper::connectWithUntitledNumbers (const css::uno::Reference< css::frame::XUntitledNumbers >& xNumbers) { // SYNCHRONIZED -> - ::osl::ResettableMutexGuard aLock(m_aMutex); + osl::MutexGuard aLock(m_aMutex); m_xUntitledNumbers = xNumbers; // <- SYNCHRONIZED @@ -132,7 +132,7 @@ void SAL_CALL TitleHelper::setTitle(const OUString& sTitle) { // SYNCHRONIZED -> { - ::osl::ResettableMutexGuard aLock(m_aMutex); + osl::MutexGuard aLock(m_aMutex); m_bExternalTitle = true; m_sTitle = sTitle; @@ -159,7 +159,7 @@ void SAL_CALL TitleHelper::titleChanged(const css::frame::TitleChangedEvent& aEv css::uno::Reference< css::frame::XTitle > xSubTitle; // SYNCHRONIZED -> { - ::osl::ResettableMutexGuard aLock(m_aMutex); + osl::MutexGuard aLock(m_aMutex); xSubTitle.set(m_xSubTitle.get (), css::uno::UNO_QUERY); } @@ -181,7 +181,7 @@ void SAL_CALL TitleHelper::documentEventOccured(const css::document::DocumentEve css::uno::Reference< css::frame::XModel > xOwner; // SYNCHRONIZED -> { - ::osl::ResettableMutexGuard aLock(m_aMutex); + osl::MutexGuard aLock(m_aMutex); xOwner.set(m_xOwner.get (), css::uno::UNO_QUERY); } @@ -203,7 +203,7 @@ void SAL_CALL TitleHelper::frameAction(const css::frame::FrameActionEvent& aEven css::uno::Reference< css::frame::XFrame > xOwner; // SYNCHRONIZED -> { - ::osl::ResettableMutexGuard aLock(m_aMutex); + osl::MutexGuard aLock(m_aMutex); xOwner.set(m_xOwner.get (), css::uno::UNO_QUERY); } @@ -232,7 +232,7 @@ void SAL_CALL TitleHelper::disposing(const css::lang::EventObject& aEvent) ::sal_Int32 nLeasedNumber; // SYNCHRONIZED -> { - ::osl::ResettableMutexGuard aLock(m_aMutex); + osl::MutexGuard aLock(m_aMutex); xOwner.set(m_xOwner.get() , css::uno::UNO_QUERY); xNumbers.set(m_xUntitledNumbers.get(), css::uno::UNO_QUERY); @@ -254,7 +254,7 @@ void SAL_CALL TitleHelper::disposing(const css::lang::EventObject& aEvent) // SYNCHRONIZED -> { - ::osl::ResettableMutexGuard aLock(m_aMutex); + osl::MutexGuard aLock(m_aMutex); m_xOwner = nullptr; m_sTitle = OUString (); @@ -268,7 +268,7 @@ void TitleHelper::impl_sendTitleChangedEvent () css::uno::Reference<css::uno::XInterface> xOwner; // SYNCHRONIZED -> { - ::osl::ResettableMutexGuard aLock(m_aMutex); + osl::MutexGuard aLock(m_aMutex); xOwner = m_xOwner; } @@ -304,7 +304,7 @@ void TitleHelper::impl_updateTitle (bool init) css::uno::Reference< css::frame::XFrame > xFrame; // SYNCHRONIZED -> { - ::osl::ResettableMutexGuard aLock(m_aMutex); + osl::MutexGuard aLock(m_aMutex); xModel.set (m_xOwner.get(), css::uno::UNO_QUERY); xController.set(m_xOwner.get(), css::uno::UNO_QUERY); @@ -333,7 +333,7 @@ void TitleHelper::impl_updateTitleForModel (const css::uno::Reference< css::fram ::sal_Int32 nLeasedNumber; // SYNCHRONIZED -> { - ::osl::ResettableMutexGuard aLock(m_aMutex); + osl::MutexGuard aLock(m_aMutex); // external title won't be updated internally! // It has to be set from outside new. @@ -394,7 +394,7 @@ void TitleHelper::impl_updateTitleForModel (const css::uno::Reference< css::fram bool bChanged; // SYNCHRONIZED -> { - ::osl::ResettableMutexGuard aLock(m_aMutex); + osl::MutexGuard aLock(m_aMutex); // WORKAROUND: the notification is currently sent always, // can be changed after shared mode is supported per UNO API @@ -416,7 +416,7 @@ void TitleHelper::impl_updateTitleForController (const css::uno::Reference< css: ::sal_Int32 nLeasedNumber; // SYNCHRONIZED -> { - ::osl::ResettableMutexGuard aLock(m_aMutex); + osl::MutexGuard aLock(m_aMutex); // external title won't be updated internally! // It has to be set from outside new. @@ -476,7 +476,7 @@ void TitleHelper::impl_updateTitleForController (const css::uno::Reference< css: bool bChanged; // SYNCHRONIZED -> { - ::osl::ResettableMutexGuard aLock(m_aMutex); + osl::MutexGuard aLock(m_aMutex); OUString sNewTitle = sTitle.makeStringAndClear (); bChanged = !init && m_sTitle != sNewTitle; @@ -496,7 +496,7 @@ void TitleHelper::impl_updateTitleForFrame (const css::uno::Reference< css::fram // SYNCHRONIZED -> { - ::osl::ResettableMutexGuard aLock(m_aMutex); + osl::MutexGuard aLock(m_aMutex); // external title won't be updated internally! // It has to be set from outside new. @@ -525,7 +525,7 @@ void TitleHelper::impl_updateTitleForFrame (const css::uno::Reference< css::fram bool bChanged; // SYNCHRONIZED -> { - ::osl::ResettableMutexGuard aLock(m_aMutex); + osl::MutexGuard aLock(m_aMutex); OUString sNewTitle = sTitle.makeStringAndClear (); bChanged = !init && m_sTitle != sNewTitle; @@ -564,7 +564,7 @@ void TitleHelper::impl_appendModuleName (OUStringBuffer& sTitle) css::uno::Reference< css::uno::XComponentContext > xContext; // SYNCHRONIZED -> { - ::osl::ResettableMutexGuard aLock(m_aMutex); + osl::MutexGuard aLock(m_aMutex); xOwner = m_xOwner.get(); xContext = m_xContext; @@ -652,7 +652,7 @@ void TitleHelper::impl_setSubTitle (const css::uno::Reference< css::frame::XTitl css::uno::Reference< css::frame::XTitle > xOldSubTitle; // SYNCHRONIZED -> { - ::osl::ResettableMutexGuard aLock(m_aMutex); + osl::MutexGuard aLock(m_aMutex); // ignore duplicate calls. Makes outside using of this helper more easy :-) xOldSubTitle.set(m_xSubTitle.get(), css::uno::UNO_QUERY); diff --git a/framework/source/fwi/threadhelp/transactionmanager.cxx b/framework/source/fwi/threadhelp/transactionmanager.cxx index 5510a24ee96e..5d78b81a9324 100644 --- a/framework/source/fwi/threadhelp/transactionmanager.cxx +++ b/framework/source/fwi/threadhelp/transactionmanager.cxx @@ -71,29 +71,29 @@ TransactionManager::~TransactionManager() void TransactionManager::setWorkingMode( EWorkingMode eMode ) { // Safe member access. - ::osl::ClearableMutexGuard aAccessGuard( m_aAccessLock ); - bool bWaitFor = false; - // Change working mode first! - if ( - ( m_eWorkingMode == E_INIT && eMode == E_WORK ) || - ( (m_eWorkingMode == E_WORK || m_eWorkingMode == E_INIT) && eMode == E_BEFORECLOSE ) || - ( m_eWorkingMode == E_BEFORECLOSE && eMode == E_CLOSE ) || - ( m_eWorkingMode == E_CLOSE && eMode == E_INIT ) - ) + bool bWaitFor = false; { - m_eWorkingMode = eMode; - if( m_eWorkingMode == E_BEFORECLOSE || m_eWorkingMode == E_CLOSE ) + osl::MutexGuard aAccessGuard(m_aAccessLock); + // Change working mode first! + if ( + (m_eWorkingMode == E_INIT && eMode == E_WORK) || + ((m_eWorkingMode == E_WORK || m_eWorkingMode == E_INIT) && eMode == E_BEFORECLOSE) || + (m_eWorkingMode == E_BEFORECLOSE && eMode == E_CLOSE) || + (m_eWorkingMode == E_CLOSE && eMode == E_INIT) + ) { - bWaitFor = true; + m_eWorkingMode = eMode; + if (m_eWorkingMode == E_BEFORECLOSE || m_eWorkingMode == E_CLOSE) + { + bWaitFor = true; + } } } - // Wait for current existing transactions then! // (Only necessary for changing to E_BEFORECLOSE or E_CLOSE!... // otherwise; if you wait at setting E_WORK another thread could finish a acquire-call during our unlock() and wait() call // ... and we will wait forever here!!!) // Don't forget to release access mutex before. - aAccessGuard.clear(); if( bWaitFor ) { m_aBarrier.wait(); diff --git a/framework/source/helper/statusindicatorfactory.cxx b/framework/source/helper/statusindicatorfactory.cxx index 1669bfea5068..b4b17c1617e4 100644 --- a/framework/source/helper/statusindicatorfactory.cxx +++ b/framework/source/helper/statusindicatorfactory.cxx @@ -492,10 +492,11 @@ void StatusIndicatorFactory::impl_hideProgress() void StatusIndicatorFactory::impl_reschedule(bool bForce) { // SAFE -> - osl::ClearableMutexGuard aReadLock(m_mutex); - if (m_bDisableReschedule) - return; - aReadLock.clear(); + { + osl::MutexGuard aReadLock(m_mutex); + if (m_bDisableReschedule) + return; + } // <- SAFE bool bReschedule = bForce; diff --git a/framework/source/jobs/job.cxx b/framework/source/jobs/job.cxx index 14c6622a5d33..6a801850b375 100644 --- a/framework/source/jobs/job.cxx +++ b/framework/source/jobs/job.cxx @@ -804,25 +804,25 @@ void SAL_CALL Job::notifyClosing( const css::lang::EventObject& ) void SAL_CALL Job::disposing( const css::lang::EventObject& aEvent ) { /* SAFE { */ - SolarMutexClearableGuard aWriteLock; - - if (m_xDesktop.is() && aEvent.Source == m_xDesktop) - { - m_xDesktop.clear(); - m_bListenOnDesktop = false; - } - else if (m_xFrame.is() && aEvent.Source == m_xFrame) - { - m_xFrame.clear(); - m_bListenOnFrame = false; - } - else if (m_xModel.is() && aEvent.Source == m_xModel) { - m_xModel.clear(); - m_bListenOnModel = false; - } + SolarMutexGuard aWriteLock; - aWriteLock.clear(); + if (m_xDesktop.is() && aEvent.Source == m_xDesktop) + { + m_xDesktop.clear(); + m_bListenOnDesktop = false; + } + else if (m_xFrame.is() && aEvent.Source == m_xFrame) + { + m_xFrame.clear(); + m_bListenOnFrame = false; + } + else if (m_xModel.is() && aEvent.Source == m_xModel) + { + m_xModel.clear(); + m_bListenOnModel = false; + } + } /* } SAFE */ die(); diff --git a/framework/source/layoutmanager/layoutmanager.cxx b/framework/source/layoutmanager/layoutmanager.cxx index 19d97528a263..16b7e099b3c6 100644 --- a/framework/source/layoutmanager/layoutmanager.cxx +++ b/framework/source/layoutmanager/layoutmanager.cxx @@ -157,7 +157,7 @@ LayoutManager::~LayoutManager() void LayoutManager::implts_createMenuBar(const OUString& rMenuBarName) { - SolarMutexClearableGuard aWriteLock; + SolarMutexGuard aWriteLock; // Create a customized menu if compatibility mode is on SvtCompatibilityViewOptions aCompOptions; @@ -172,8 +172,6 @@ void LayoutManager::implts_createMenuBar(const OUString& rMenuBarName) m_xMenuBar = implts_createElement( rMenuBarName ); if ( m_xMenuBar.is() ) { - SolarMutexGuard aGuard; - SystemWindow* pSysWindow = getTopSystemWindow( m_xContainerWindow ); if ( pSysWindow ) { @@ -211,7 +209,6 @@ void LayoutManager::implts_createMenuBar(const OUString& rMenuBarName) } } } - aWriteLock.clear(); } // Internal helper function @@ -538,7 +535,7 @@ bool LayoutManager::readWindowStateData( const OUString& aName, UIElement& rElem { bool bGetSettingsState( false ); - SolarMutexResettableGuard aWriteLock; + SolarMutexClearableGuard aWriteLock; bool bGlobalSettings( bInGlobalSettings ); if ( rGlobalSettings == nullptr ) { @@ -628,9 +625,10 @@ bool LayoutManager::readWindowStateData( const OUString& aName, UIElement& rElem { if ( pGlobalSettings->HasToolbarStatesInfo()) { - SolarMutexClearableGuard aWriteLock2; - bInGlobalSettings = true; - aWriteLock2.clear(); + { + SolarMutexGuard aWriteLock2; + bInGlobalSettings = true; + } uno::Any aValue; if ( pGlobalSettings->GetToolbarStateInfo( @@ -664,7 +662,7 @@ bool LayoutManager::readWindowStateData( const OUString& aName, UIElement& rElem void LayoutManager::implts_writeWindowStateData( const OUString& aName, const UIElement& rElementData ) { - SolarMutexResettableGuard aWriteLock; + SolarMutexClearableGuard aWriteLock; Reference< XNameAccess > xPersistentWindowState( m_xPersistentWindowState ); aWriteLock.clear(); @@ -730,10 +728,6 @@ void LayoutManager::implts_writeWindowStateData( const OUString& aName, const UI { } } - - // Reset flag - aWriteLock.reset(); - aWriteLock.clear(); } ::Size LayoutManager::implts_getContainerWindowOutputSize() @@ -777,9 +771,10 @@ Reference< XUIElement > LayoutManager::implts_createElement( const OUString& aNa void LayoutManager::implts_setVisibleState( bool bShow ) { - SolarMutexClearableGuard aWriteLock; - m_aStatusBarElement.m_bMasterHide = !bShow; - aWriteLock.clear(); + { + SolarMutexGuard aWriteLock; + m_aStatusBarElement.m_bMasterHide = !bShow; + } implts_updateUIElementsVisibleState( bShow ); } @@ -847,12 +842,13 @@ void LayoutManager::implts_updateUIElementsVisibleState( bool bSetVisible ) void LayoutManager::implts_setCurrentUIVisibility( bool bShow ) { - SolarMutexClearableGuard aWriteLock; - if ( !bShow && m_aStatusBarElement.m_bVisible && m_aStatusBarElement.m_xUIElement.is() ) - m_aStatusBarElement.m_bMasterHide = true; - else if ( bShow && m_aStatusBarElement.m_bVisible ) - m_aStatusBarElement.m_bMasterHide = false; - aWriteLock.clear(); + { + SolarMutexGuard aWriteLock; + if (!bShow && m_aStatusBarElement.m_bVisible && m_aStatusBarElement.m_xUIElement.is()) + m_aStatusBarElement.m_bMasterHide = true; + else if (bShow && m_aStatusBarElement.m_bVisible) + m_aStatusBarElement.m_bMasterHide = false; + } implts_updateUIElementsVisibleState( bShow ); } @@ -875,14 +871,15 @@ void LayoutManager::implts_destroyStatusBar() void LayoutManager::implts_createStatusBar( const OUString& aStatusBarName ) { - SolarMutexClearableGuard aWriteLock; - if ( !m_aStatusBarElement.m_xUIElement.is() ) { - implts_readStatusBarState( aStatusBarName ); - m_aStatusBarElement.m_aName = aStatusBarName; - m_aStatusBarElement.m_xUIElement = implts_createElement( aStatusBarName ); + SolarMutexGuard aWriteLock; + if (!m_aStatusBarElement.m_xUIElement.is()) + { + implts_readStatusBarState(aStatusBarName); + m_aStatusBarElement.m_aName = aStatusBarName; + m_aStatusBarElement.m_xUIElement = implts_createElement(aStatusBarName); + } } - aWriteLock.clear(); implts_createProgressBar(); } @@ -1036,7 +1033,7 @@ bool LayoutManager::implts_showProgressBar() Reference< awt::XWindow > xWindow; /* SAFE AREA ----------------------------------------------------------------------------------------------- */ - SolarMutexClearableGuard aWriteLock; + SolarMutexGuard aWriteLock; xStatusBar.set( m_aStatusBarElement.m_xUIElement, UNO_QUERY ); xProgressBar.set( m_aProgressBarElement.m_xUIElement, UNO_QUERY ); bool bVisible( m_bVisible ); @@ -1055,10 +1052,7 @@ bool LayoutManager::implts_showProgressBar() xWindow = pWrapper->getStatusBar(); } } - aWriteLock.clear(); - /* SAFE AREA ----------------------------------------------------------------------------------------------- */ - SolarMutexGuard aGuard; VclPtr<vcl::Window> pWindow = VCLUnoHelper::GetWindow( xWindow ); if ( pWindow ) { @@ -1336,7 +1330,6 @@ void SAL_CALL LayoutManager::setDockingAreaAcceptor( const Reference< ui::XDocki // #i37884# set initial visibility state - in the plugin case the container window is already shown // and we get no notification anymore { - SolarMutexGuard aGuard; VclPtr<vcl::Window> pContainerWindow = VCLUnoHelper::GetWindow( m_xContainerWindow ); if( pContainerWindow ) m_bParentWindowVisible = pContainerWindow->IsVisible(); @@ -1735,9 +1728,10 @@ sal_Bool SAL_CALL LayoutManager::showElement( const OUString& aName ) if ( aElementType.equalsIgnoreAsciiCase("menubar") && aElementName.equalsIgnoreAsciiCase("menubar") ) { - SolarMutexClearableGuard aWriteLock; - m_bMenuVisible = true; - aWriteLock.clear(); + { + SolarMutexGuard aWriteLock; + m_bMenuVisible = true; + } bResult = implts_resetMenuBar(); bNotify = bResult; @@ -2204,10 +2198,11 @@ void SAL_CALL LayoutManager::unlock() #endif // conform to documentation: unlock with lock count == 0 means force a layout - SolarMutexClearableGuard aWriteLock; - if ( bDoLayout ) - m_aAsyncLayoutTimer.Stop(); - aWriteLock.clear(); + { + SolarMutexGuard aWriteLock; + if (bDoLayout) + m_aAsyncLayoutTimer.Stop(); + } Any a( nLockCount ); implts_notifyListeners( frame::LayoutManagerEvents::UNLOCK, a ); @@ -2274,9 +2269,6 @@ bool LayoutManager::implts_doLayout( bool bForceRequestBorderSpace, bool bOuterR { bLayouted = true; - SolarMutexResettableGuard aWriteGuard; - aWriteGuard.clear(); - awt::Rectangle aDockSpace( implts_calcDockingAreaSizes() ); awt::Rectangle aBorderSpace( aDockSpace ); bool bGotRequestedBorderSpace( true ); @@ -2320,10 +2312,9 @@ bool LayoutManager::implts_doLayout( bool bForceRequestBorderSpace, bool bOuterR if ( bGotRequestedBorderSpace ) { - aWriteGuard.reset(); + SolarMutexGuard aWriteGuard; m_aDockingArea = aBorderSpace; m_bMustDoLayout = false; - aWriteGuard.clear(); } } @@ -2355,9 +2346,6 @@ bool LayoutManager::implts_doLayout( bool bForceRequestBorderSpace, bool bOuterR } xDockingAreaAcceptor->setDockingAreaSpace( aBorderSpace ); - - aWriteGuard.reset(); - aWriteGuard.clear(); } } @@ -2506,7 +2494,7 @@ void LayoutManager::implts_updateMenuBarClose() bool LayoutManager::implts_resetMenuBar() { /* SAFE AREA ----------------------------------------------------------------------------------------------- */ - SolarMutexClearableGuard aWriteLock; + SolarMutexGuard aWriteLock; bool bMenuVisible( m_bMenuVisible ); Reference< awt::XWindow > xContainerWindow( m_xContainerWindow ); @@ -2519,10 +2507,7 @@ bool LayoutManager::implts_resetMenuBar() if ( pMenuBarWrapper ) pSetMenuBar = static_cast<MenuBar*>(pMenuBarWrapper->GetMenuBarManager()->GetMenuBar()); } - aWriteLock.clear(); - /* SAFE AREA ----------------------------------------------------------------------------------------------- */ - SolarMutexGuard aGuard; SystemWindow* pSysWindow = getTopSystemWindow( xContainerWindow ); if ( pSysWindow && bMenuVisible && pSetMenuBar ) { @@ -2536,7 +2521,7 @@ bool LayoutManager::implts_resetMenuBar() void LayoutManager::implts_createMSCompatibleMenuBar( const OUString& aName ) { - SolarMutexClearableGuard aWriteLock; + SolarMutexGuard aWriteLock; // Find Forms menu in the original menubar m_xMenuBar = implts_createElement( aName ); @@ -2584,8 +2569,6 @@ void LayoutManager::implts_createMSCompatibleMenuBar( const OUString& aName ) if ( xFormsMenuComp.is() ) xFormsMenuComp->dispose(); xFormsMenu.clear(); - - aWriteLock.clear(); } IMPL_LINK_NOARG(LayoutManager, MenuBarClose, void*, void) @@ -2729,12 +2712,12 @@ void SAL_CALL LayoutManager::windowHidden( const lang::EventObject& aEvent ) IMPL_LINK_NOARG(LayoutManager, AsyncLayoutHdl, Timer *, void) { - SolarMutexClearableGuard aReadLock; - - if( !m_xContainerWindow.is() ) - return; + { + SolarMutexGuard aReadLock; - aReadLock.clear(); + if (!m_xContainerWindow.is()) + return; + } implts_setDockingAreaWindowSizes(); implts_doLayout( true, false ); @@ -2748,9 +2731,10 @@ void SAL_CALL LayoutManager::frameAction( const FrameActionEvent& aEvent ) { SAL_INFO( "fwk", "framework (cd100003) ::LayoutManager::frameAction (COMPONENT_ATTACHED|REATTACHED)" ); - SolarMutexClearableGuard aWriteLock; - m_bMustDoLayout = true; - aWriteLock.clear(); + { + SolarMutexGuard aWriteLock; + m_bMustDoLayout = true; + } implts_reset( true ); implts_doLayout( true, false ); @@ -2775,94 +2759,94 @@ void SAL_CALL LayoutManager::disposing( const lang::EventObject& rEvent ) bool bDisposeAndClear( false ); /* SAFE AREA ----------------------------------------------------------------------------------------------- */ - SolarMutexClearableGuard aWriteLock; - - if ( rEvent.Source == Reference< XInterface >( m_xFrame, UNO_QUERY )) { - // Our frame gets disposed, release all our references that depends on a working frame reference. - - setDockingAreaAcceptor( Reference< ui::XDockingAreaAcceptor >() ); + SolarMutexGuard aWriteLock; - // destroy all elements, it's possible that detaching is NOT called! - implts_destroyElements(); - impl_clearUpMenuBar(); - m_xMenuBar.clear(); - VclPtr<Menu> pMenuBar; - if (m_xInplaceMenuBar.is()) + if (rEvent.Source == Reference<XInterface>(m_xFrame, UNO_QUERY)) { - pMenuBar = m_xInplaceMenuBar->GetMenuBar(); - m_xInplaceMenuBar->dispose(); - m_xInplaceMenuBar.clear(); - } - pMenuBar.disposeAndClear(); - m_xContainerWindow.clear(); - m_xContainerTopWindow.clear(); + // Our frame gets disposed, release all our references that depends on a working frame reference. - // forward disposing call to toolbar manager - if ( m_xToolbarManager.is() ) - m_xToolbarManager->disposing(rEvent); + setDockingAreaAcceptor(Reference<ui::XDockingAreaAcceptor>()); - if ( m_xModuleCfgMgr.is() ) - { - try - { - Reference< XUIConfiguration > xModuleCfgMgr( m_xModuleCfgMgr, UNO_QUERY ); - xModuleCfgMgr->removeConfigurationListener( - Reference< XUIConfigurationListener >( static_cast< OWeakObject* >( this ), UNO_QUERY )); - } - catch (const Exception&) + // destroy all elements, it's possible that detaching is NOT called! + implts_destroyElements(); + impl_clearUpMenuBar(); + m_xMenuBar.clear(); + VclPtr<Menu> pMenuBar; + if (m_xInplaceMenuBar.is()) { + pMenuBar = m_xInplaceMenuBar->GetMenuBar(); + m_xInplaceMenuBar->dispose(); + m_xInplaceMenuBar.clear(); } - } + pMenuBar.disposeAndClear(); + m_xContainerWindow.clear(); + m_xContainerTopWindow.clear(); - if ( m_xDocCfgMgr.is() ) - { - try + // forward disposing call to toolbar manager + if (m_xToolbarManager.is()) + m_xToolbarManager->disposing(rEvent); + + if (m_xModuleCfgMgr.is()) { - Reference< XUIConfiguration > xDocCfgMgr( m_xDocCfgMgr, UNO_QUERY ); - xDocCfgMgr->removeConfigurationListener( - Reference< XUIConfigurationListener >( static_cast< OWeakObject* >( this ), UNO_QUERY )); + try + { + Reference<XUIConfiguration> xModuleCfgMgr(m_xModuleCfgMgr, UNO_QUERY); + xModuleCfgMgr->removeConfigurationListener(Reference<XUIConfigurationListener>( + static_cast<OWeakObject*>(this), UNO_QUERY)); + } + catch (const Exception&) + { + } } - catch (const Exception&) + + if (m_xDocCfgMgr.is()) { + try + { + Reference<XUIConfiguration> xDocCfgMgr(m_xDocCfgMgr, UNO_QUERY); + xDocCfgMgr->removeConfigurationListener(Reference<XUIConfigurationListener>( + static_cast<OWeakObject*>(this), UNO_QUERY)); + } + catch (const Exception&) + { + } } - } - m_xDocCfgMgr.clear(); - m_xModuleCfgMgr.clear(); - m_xFrame.clear(); - m_pGlobalSettings.reset(); + m_xDocCfgMgr.clear(); + m_xModuleCfgMgr.clear(); + m_xFrame.clear(); + m_pGlobalSettings.reset(); - bDisposeAndClear = true; - } - else if ( rEvent.Source == Reference< XInterface >( m_xContainerWindow, UNO_QUERY )) - { - // Our container window gets disposed. Remove all user interface elements. - ToolbarLayoutManager* pToolbarManager = m_xToolbarManager.get(); - if ( pToolbarManager ) - { - uno::Reference< awt::XWindowPeer > aEmptyWindowPeer; - pToolbarManager->setParentWindow( aEmptyWindowPeer ); + bDisposeAndClear = true; } - impl_clearUpMenuBar(); - m_xMenuBar.clear(); - VclPtr<Menu> pMenuBar; - if (m_xInplaceMenuBar.is()) + else if (rEvent.Source == Reference<XInterface>(m_xContainerWindow, UNO_QUERY)) { - pMenuBar = m_xInplaceMenuBar->GetMenuBar(); - m_xInplaceMenuBar->dispose(); - m_xInplaceMenuBar.clear(); + // Our container window gets disposed. Remove all user interface elements. + ToolbarLayoutManager* pToolbarManager = m_xToolbarManager.get(); + if (pToolbarManager) + { + uno::Reference<awt::XWindowPeer> aEmptyWindowPeer; + pToolbarManager->setParentWindow(aEmptyWindowPeer); + } + impl_clearUpMenuBar(); + m_xMenuBar.clear(); + VclPtr<Menu> pMenuBar; + if (m_xInplaceMenuBar.is()) + { + pMenuBar = m_xInplaceMenuBar->GetMenuBar(); + m_xInplaceMenuBar->dispose(); + m_xInplaceMenuBar.clear(); + } + pMenuBar.disposeAndClear(); + m_xContainerWindow.clear(); + m_xContainerTopWindow.clear(); } - pMenuBar.disposeAndClear(); - m_xContainerWindow.clear(); - m_xContainerTopWindow.clear(); + else if (rEvent.Source == Reference<XInterface>(m_xDocCfgMgr, UNO_QUERY)) + m_xDocCfgMgr.clear(); + else if (rEvent.Source == Reference<XInterface>(m_xModuleCfgMgr, UNO_QUERY)) + m_xModuleCfgMgr.clear(); } - else if ( rEvent.Source == Reference< XInterface >( m_xDocCfgMgr, UNO_QUERY )) - m_xDocCfgMgr.clear(); - else if ( rEvent.Source == Reference< XInterface >( m_xModuleCfgMgr , UNO_QUERY )) - m_xModuleCfgMgr.clear(); - - aWriteLock.clear(); /* SAFE AREA ----------------------------------------------------------------------------------------------- */ // Send disposing to our listener when we have lost our frame. diff --git a/framework/source/layoutmanager/toolbarlayoutmanager.cxx b/framework/source/layoutmanager/toolbarlayoutmanager.cxx index 8d1d4aed2e0a..aca93c4e2f03 100644 --- a/framework/source/layoutmanager/toolbarlayoutmanager.cxx +++ b/framework/source/layoutmanager/toolbarlayoutmanager.cxx @@ -350,14 +350,15 @@ tools::Rectangle ToolbarLayoutManager::implts_calcDockingArea() void ToolbarLayoutManager::reset() { - SolarMutexClearableGuard aWriteLock; - uno::Reference< ui::XUIConfigurationManager > xModuleCfgMgr( m_xModuleCfgMgr ); - uno::Reference< ui::XUIConfigurationManager > xDocCfgMgr( m_xDocCfgMgr ); - m_xModuleCfgMgr.clear(); - m_xDocCfgMgr.clear(); - m_ePreviewDetection = PREVIEWFRAME_UNKNOWN; - m_bComponentAttached = false; - aWriteLock.clear(); + { + SolarMutexGuard aWriteLock; + uno::Reference< ui::XUIConfigurationManager > xModuleCfgMgr(m_xModuleCfgMgr); + uno::Reference< ui::XUIConfigurationManager > xDocCfgMgr(m_xDocCfgMgr); + m_xModuleCfgMgr.clear(); + m_xDocCfgMgr.clear(); + m_ePreviewDetection = PREVIEWFRAME_UNKNOWN; + m_bComponentAttached = false; + } destroyToolbars(); resetDockingArea(); @@ -499,40 +500,41 @@ bool ToolbarLayoutManager::createToolbar( const OUString& rResourceURL ) bool bFloating = false; /* SAFE AREA ----------------------------------------------------------------------------------------------- */ - SolarMutexClearableGuard aWriteLock; - - UIElement& rElement = impl_findToolbar( rResourceURL ); - if (rElement.m_xUIElement.is()) - { - // somebody else must have created it while we released - // the SolarMutex - just dispose our new instance and - // do nothing. (We have to dispose either the new or the - // existing m_xUIElement.) - aWriteLock.clear(); - uno::Reference<lang::XComponent> const xC(xUIElement, uno::UNO_QUERY); - xC->dispose(); - return false; - } - if ( !rElement.m_aName.isEmpty() ) { - // Reuse a local entry so we are able to use the latest - // UI changes for this document. - implts_setElementData( rElement, xDockWindow ); - rElement.m_xUIElement = xUIElement; - bVisible = rElement.m_bVisible; - bFloating = rElement.m_bFloating; - } - else - { - // Create new UI element and try to read its state data - UIElement aNewToolbar( rResourceURL, UIRESOURCETYPE_TOOLBAR, xUIElement ); - implts_readWindowStateData( rResourceURL, aNewToolbar ); - implts_setElementData( aNewToolbar, xDockWindow ); - implts_insertToolbar( aNewToolbar ); - bVisible = aNewToolbar.m_bVisible; - bFloating = rElement.m_bFloating; + SolarMutexClearableGuard aWriteLock; + + UIElement& rElement = impl_findToolbar(rResourceURL); + if (rElement.m_xUIElement.is()) + { + // somebody else must have created it while we released + // the SolarMutex - just dispose our new instance and + // do nothing. (We have to dispose either the new or the + // existing m_xUIElement.) + aWriteLock.clear(); + uno::Reference<lang::XComponent> const xC(xUIElement, uno::UNO_QUERY); + xC->dispose(); + return false; + } + if (!rElement.m_aName.isEmpty()) + { + // Reuse a local entry so we are able to use the latest + // UI changes for this document. + implts_setElementData(rElement, xDockWindow); + rElement.m_xUIElement = xUIElement; + bVisible = rElement.m_bVisible; + bFloating = rElement.m_bFloating; + } + else + { + // Create new UI element and try to read its state data + UIElement aNewToolbar(rResourceURL, UIRESOURCETYPE_TOOLBAR, xUIElement); + implts_readWindowStateData(rResourceURL, aNewToolbar); + implts_setElementData(aNewToolbar, xDockWindow); + implts_insertToolbar(aNewToolbar); + bVisible = aNewToolbar.m_bVisible; + bFloating = rElement.m_bFloating; + } } - aWriteLock.clear(); /* SAFE AREA ----------------------------------------------------------------------------------------------- */ // set toolbar menu style according to customize command state @@ -570,20 +572,21 @@ bool ToolbarLayoutManager::destroyToolbar( const OUString& rResourceURL ) bool bMustLayouted( false ); bool bMustBeDestroyed( !rResourceURL.startsWith("private:resource/toolbar/addon_") ); - SolarMutexClearableGuard aWriteLock; - for (auto & elem : m_aUIElements) { - if ( elem.m_aName == rResourceURL ) + SolarMutexGuard aWriteLock; + for (auto & elem : m_aUIElements) { - xComponent.set( elem.m_xUIElement, uno::UNO_QUERY ); - if ( bMustBeDestroyed ) - elem.m_xUIElement.clear(); - else - elem.m_bVisible = false; - break; + if (elem.m_aName == rResourceURL) + { + xComponent.set(elem.m_xUIElement, uno::UNO_QUERY); + if (bMustBeDestroyed) + elem.m_xUIElement.clear(); + else + elem.m_bVisible = false; + break; + } } } - aWriteLock.clear(); uno::Reference< ui::XUIElement > xUIElement( xComponent, uno::UNO_QUERY ); if ( xUIElement.is() ) @@ -646,10 +649,11 @@ void ToolbarLayoutManager::destroyToolbars() UIElementVector aUIElementVector; implts_getUIElementVectorCopy( aUIElementVector ); - SolarMutexClearableGuard aWriteLock; - m_aUIElements.clear(); - m_bLayoutDirty = true; - aWriteLock.clear(); + { + SolarMutexGuard aWriteLock; + m_aUIElements.clear(); + m_bLayoutDirty = true; + } for (auto const& elem : aUIElementVector) { @@ -881,13 +885,15 @@ bool ToolbarLayoutManager::dockAllToolbars() { std::vector< OUString > aToolBarNameVector; - SolarMutexClearableGuard aReadLock; - for (auto const& elem : m_aUIElements) { - if ( elem.m_aType == "toolbar" && elem.m_xUIElement.is() && elem.m_bFloating && elem.m_bVisible ) - aToolBarNameVector.push_back( elem.m_aName ); + SolarMutexGuard aReadLock; + for (auto const& elem : m_aUIElements) + { + if (elem.m_aType == "toolbar" && elem.m_xUIElement.is() && elem.m_bFloating + && elem.m_bVisible) + aToolBarNameVector.push_back(elem.m_aName); + } } - aReadLock.clear(); bool bResult(true); const sal_uInt32 nCount = aToolBarNameVector.size(); @@ -1011,13 +1017,14 @@ void ToolbarLayoutManager::setParentWindow( uno::Reference< awt::XWindow > xRightDockWindow( createToolkitWindow( m_xContext, xParentWindow, DOCKINGAREASTRING ), uno::UNO_QUERY ); uno::Reference< awt::XWindow > xBottomDockWindow( createToolkitWindow( m_xContext, xParentWindow, DOCKINGAREASTRING ), uno::UNO_QUERY ); - SolarMutexClearableGuard aWriteLock; - m_xContainerWindow.set( xParentWindow, uno::UNO_QUERY ); - m_xDockAreaWindows[int(ui::DockingArea_DOCKINGAREA_TOP)] = xTopDockWindow; - m_xDockAreaWindows[int(ui::DockingArea_DOCKINGAREA_LEFT)] = xLeftDockWindow; - m_xDockAreaWindows[int(ui::DockingArea_DOCKINGAREA_RIGHT)] = xRightDockWindow; - m_xDockAreaWindows[int(ui::DockingArea_DOCKINGAREA_BOTTOM)] = xBottomDockWindow; - aWriteLock.clear(); + { + SolarMutexGuard aWriteLock; + m_xContainerWindow.set(xParentWindow, uno::UNO_QUERY); + m_xDockAreaWindows[int(ui::DockingArea_DOCKINGAREA_TOP)] = xTopDockWindow; + m_xDockAreaWindows[int(ui::DockingArea_DOCKINGAREA_LEFT)] = xLeftDockWindow; + m_xDockAreaWindows[int(ui::DockingArea_DOCKINGAREA_RIGHT)] = xRightDockWindow; + m_xDockAreaWindows[int(ui::DockingArea_DOCKINGAREA_BOTTOM)] = xBottomDockWindow; + } if ( xParentWindow.is() ) { @@ -1541,7 +1548,7 @@ bool ToolbarLayoutManager::implts_readWindowStateData( const OUString& aName, UI void ToolbarLayoutManager::implts_writeWindowStateData( const UIElement& rElementData ) { - SolarMutexResettableGuard aWriteLock; + SolarMutexClearableGuard aWriteLock; uno::Reference< container::XNameAccess > xPersistentWindowState( m_xPersistentWindowState ); aWriteLock.clear(); @@ -1609,10 +1616,6 @@ void ToolbarLayoutManager::implts_writeWindowStateData( const UIElement& rElemen { } } - - // Reset flag - aWriteLock.reset(); - aWriteLock.clear(); } /****************************************************************************** @@ -1804,10 +1807,11 @@ void ToolbarLayoutManager::implts_getUIElementVectorCopy( UIElementVector& rCopy uno::Reference< awt::XWindow > xTopDockingAreaWindow; uno::Reference< awt::XWindow > xBottomDockingAreaWindow; - SolarMutexClearableGuard aReadLock; - xTopDockingAreaWindow = m_xDockAreaWindows[int(ui::DockingArea_DOCKINGAREA_TOP)]; - xBottomDockingAreaWindow = m_xDockAreaWindows[int(ui::DockingArea_DOCKINGAREA_BOTTOM)]; - aReadLock.clear(); + { + SolarMutexGuard aReadLock; + xTopDockingAreaWindow = m_xDockAreaWindows[int(ui::DockingArea_DOCKINGAREA_TOP)]; + xBottomDockingAreaWindow = m_xDockAreaWindows[int(ui::DockingArea_DOCKINGAREA_BOTTOM)]; + } if ( xTopDockingAreaWindow.is() ) aSize.setWidth( xTopDockingAreaWindow->getPosSize().Height ); @@ -1827,43 +1831,48 @@ void ToolbarLayoutManager::implts_getDockingAreaElementInfos( ui::DockingArea eD uno::Reference< awt::XWindow > xDockAreaWindow; /* SAFE AREA ----------------------------------------------------------------------------------------------- */ - SolarMutexClearableGuard aReadLock; - aWindowVector.reserve(m_aUIElements.size()); - xDockAreaWindow = m_xDockAreaWindows[static_cast<int>(eDockingArea)]; - for (auto const& elem : m_aUIElements) { - if ( elem.m_aDockedData.m_nDockedArea == eDockingArea && elem.m_bVisible ) + SolarMutexGuard aReadLock; + aWindowVector.reserve(m_aUIElements.size()); + xDockAreaWindow = m_xDockAreaWindows[static_cast<int>(eDockingArea)]; + for (auto const& elem : m_aUIElements) { - uno::Reference< ui::XUIElement > xUIElement( elem.m_xUIElement ); - if ( xUIElement.is() ) + if (elem.m_aDockedData.m_nDockedArea == eDockingArea && elem.m_bVisible) { - uno::Reference< awt::XWindow > xWindow( xUIElement->getRealInterface(), uno::UNO_QUERY ); - uno::Reference< awt::XDockableWindow > xDockWindow( xWindow, uno::UNO_QUERY ); - if ( xDockWindow.is() ) + uno::Reference<ui::XUIElement> xUIElement(elem.m_xUIElement); + if (xUIElement.is()) { - if (!elem.m_bFloating) + uno::Reference<awt::XWindow> xWindow(xUIElement->getRealInterface(), + uno::UNO_QUERY); + uno::Reference<awt::XDockableWindow> xDockWindow(xWindow, uno::UNO_QUERY); + if (xDockWindow.is()) { - // docked windows - aWindowVector.push_back(elem); - } - else - { - // floating windows - VclPtr<vcl::Window> pWindow = VCLUnoHelper::GetWindow(xWindow); - DockingManager* pDockMgr = vcl::Window::GetDockingManager(); - if (pDockMgr != nullptr) + if (!elem.m_bFloating) + { + // docked windows + aWindowVector.push_back(elem); + } + else { - ImplDockingWindowWrapper* pWrapper = pDockMgr->GetDockingWindowWrapper(pWindow); - if (pWrapper != nullptr && pWrapper->GetFloatingWindow()) + // floating windows + VclPtr<vcl::Window> pWindow = VCLUnoHelper::GetWindow(xWindow); + DockingManager* pDockMgr = vcl::Window::GetDockingManager(); + if (pDockMgr != nullptr) { - // update the position data of the floating window - if (pWrapper->GetFloatingWindow()->UpdatePositionData()) + ImplDockingWindowWrapper* pWrapper + = pDockMgr->GetDockingWindowWrapper(pWindow); + if (pWrapper != nullptr && pWrapper->GetFloatingWindow()) { - awt::Rectangle aTmpRect = xWindow->getPosSize(); - UIElement uiElem = elem; - uiElem.m_aFloatingData.m_aPos = awt::Point(aTmpRect.X, aTmpRect.Y); - implts_setToolbar(uiElem); - implts_writeWindowStateData(uiElem); + // update the position data of the floating window + if (pWrapper->GetFloatingWindow()->UpdatePositionData()) + { + awt::Rectangle aTmpRect = xWindow->getPosSize(); + UIElement uiElem = elem; + uiElem.m_aFloatingData.m_aPos + = awt::Point(aTmpRect.X, aTmpRect.Y); + implts_setToolbar(uiElem); + implts_writeWindowStateData(uiElem); + } } } } @@ -1872,7 +1881,6 @@ void ToolbarLayoutManager::implts_getDockingAreaElementInfos( ui::DockingArea eD } } } - aReadLock.clear(); /* SAFE AREA ----------------------------------------------------------------------------------------------- */ rRowColumnsWindowData.clear(); @@ -2036,29 +2044,32 @@ void ToolbarLayoutManager::implts_getDockingAreaElementInfoOnSingleRowCol( ui::D bool bHorzDockArea = isHorizontalDockingArea( eDockingArea ); /* SAFE AREA ----------------------------------------------------------------------------------------------- */ - SolarMutexClearableGuard aReadLock; - for (auto const& elem : m_aUIElements) { - if ( elem.m_aDockedData.m_nDockedArea == eDockingArea ) + SolarMutexGuard aReadLock; + for (auto const& elem : m_aUIElements) { - bool bSameRowCol = bHorzDockArea ? ( elem.m_aDockedData.m_aPos.Y == nRowCol ) : ( elem.m_aDockedData.m_aPos.X == nRowCol ); - uno::Reference< ui::XUIElement > xUIElement( elem.m_xUIElement ); - - if ( bSameRowCol && xUIElement.is() ) + if (elem.m_aDockedData.m_nDockedArea == eDockingArea) { - uno::Reference< awt::XWindow > xWindow( xUIElement->getRealInterface(), uno::UNO_QUERY ); - if ( xWindow.is() ) + bool bSameRowCol = bHorzDockArea ? (elem.m_aDockedData.m_aPos.Y == nRowCol) + : (elem.m_aDockedData.m_aPos.X == nRowCol); + uno::Reference<ui::XUIElement> xUIElement(elem.m_xUIElement); + + if (bSameRowCol && xUIElement.is()) { - SolarMutexGuard aGuard; - VclPtr<vcl::Window> pWindow = VCLUnoHelper::GetWindow( xWindow ); - uno::Reference< awt::XDockableWindow > xDockWindow( xWindow, uno::UNO_QUERY ); - if ( pWindow && elem.m_bVisible && xDockWindow.is() && !elem.m_bFloating ) - aWindowVector.push_back(elem); // docked windows + uno::Reference<awt::XWindow> xWindow(xUIElement->getRealInterface(), + uno::UNO_QUERY); + if (xWindow.is()) + { + SolarMutexGuard aGuard; + VclPtr<vcl::Window> pWindow = VCLUnoHelper::GetWindow(xWindow); + uno::Reference<awt::XDockableWindow> xDockWindow(xWindow, uno::UNO_QUERY); + if (pWindow && elem.m_bVisible && xDockWindow.is() && !elem.m_bFloating) + aWindowVector.push_back(elem); // docked windows + } } } } } - aReadLock.clear(); /* SAFE AREA ----------------------------------------------------------------------------------------------- */ // Initialize structure @@ -2248,15 +2259,12 @@ void ToolbarLayoutManager::implts_findNextDockingPos( ui::DockingArea DockingAre uno::Reference< awt::XWindow > xDockingWindow( m_xDockAreaWindows[static_cast<int>(DockingArea)] ); ::Size aDockingWinSize; vcl::Window* pDockingWindow( nullptr ); - aReadLock.clear(); - { - // Retrieve output size from container Window - SolarMutexGuard aGuard; - pDockingWindow = VCLUnoHelper::GetWindow( xDockingWindow ).get(); - if ( pDockingWindow ) - aDockingWinSize = pDockingWindow->GetOutputSizePixel(); - } + // Retrieve output size from container Window + pDockingWindow = VCLUnoHelper::GetWindow( xDockingWindow ).get(); + if ( pDockingWindow ) + aDockingWinSize = pDockingWindow->GetOutputSizePixel(); + aReadLock.clear(); sal_Int32 nFreeRowColPixelPos( 0 ); sal_Int32 nMaxSpace( 0 ); @@ -3103,26 +3111,29 @@ void ToolbarLayoutManager::implts_renumberRowColumnData( sal_Int32 nRowCol( bHorzDockingArea ? rUIElement.m_aDockedData.m_aPos.Y : rUIElement.m_aDockedData.m_aPos.X ); /* SAFE AREA ----------------------------------------------------------------------------------------------- */ - SolarMutexClearableGuard aWriteLock; - for (auto & elem : m_aUIElements) { - if (( elem.m_aDockedData.m_nDockedArea == eDockingArea ) && ( elem.m_aName != rUIElement.m_aName )) + SolarMutexGuard aWriteLock; + for (auto& elem : m_aUIElements) { - // Don't change toolbars without a valid docking position! - if ( isDefaultPos( elem.m_aDockedData.m_aPos )) - continue; - - sal_Int32 nWindowRowCol = bHorzDockingArea ? elem.m_aDockedData.m_aPos.Y : elem.m_aDockedData.m_aPos.X; - if ( nWindowRowCol >= nRowCol ) + if ((elem.m_aDockedData.m_nDockedArea == eDockingArea) + && (elem.m_aName != rUIElement.m_aName)) { - if ( bHorzDockingArea ) - elem.m_aDockedData.m_aPos.Y += 1; - else - elem.m_aDockedData.m_aPos.X += 1; + // Don't change toolbars without a valid docking position! + if (isDefaultPos(elem.m_aDockedData.m_aPos)) + continue; + + sal_Int32 nWindowRowCol + = bHorzDockingArea ? elem.m_aDockedData.m_aPos.Y : elem.m_aDockedData.m_aPos.X; + if (nWindowRowCol >= nRowCol) + { + if (bHorzDockingArea) + elem.m_aDockedData.m_aPos.Y += 1; + else + elem.m_aDockedData.m_aPos.X += 1; + } } } } - aWriteLock.clear(); /* SAFE AREA ----------------------------------------------------------------------------------------------- */ // We have to change the persistent window state part @@ -3738,29 +3749,31 @@ void SAL_CALL ToolbarLayoutManager::closed( const lang::EventObject& e ) OUString aName; UIElement aUIElement; - SolarMutexClearableGuard aWriteLock; - for (auto & elem : m_aUIElements) { - uno::Reference< ui::XUIElement > xUIElement( elem.m_xUIElement ); - if ( xUIElement.is() ) + SolarMutexGuard aWriteLock; + for (auto& elem : m_aUIElements) { - uno::Reference< uno::XInterface > xIfac( xUIElement->getRealInterface(), uno::UNO_QUERY ); - if ( xIfac == e.Source ) + uno::Reference<ui::XUIElement> xUIElement(elem.m_xUIElement); + if (xUIElement.is()) { - aName = elem.m_aName; + uno::Reference<uno::XInterface> xIfac(xUIElement->getRealInterface(), + uno::UNO_QUERY); + if (xIfac == e.Source) + { + aName = elem.m_aName; - // user closes a toolbar => - // context sensitive toolbar: only destroy toolbar and store state. - // non context sensitive toolbar: make it invisible, store state and destroy it. - if ( !elem.m_bContextSensitive ) - elem.m_bVisible = false; + // user closes a toolbar => + // context sensitive toolbar: only destroy toolbar and store state. + // non context sensitive toolbar: make it invisible, store state and destroy it. + if (!elem.m_bContextSensitive) + elem.m_bVisible = false; - aUIElement = elem; - break; + aUIElement = elem; + break; + } } } } - aWriteLock.clear(); // destroy element if ( !aName.isEmpty() ) diff --git a/framework/source/loadenv/loadenv.cxx b/framework/source/loadenv/loadenv.cxx index 0be9ad70e82e..a5b2f36f38e2 100644 --- a/framework/source/loadenv/loadenv.cxx +++ b/framework/source/loadenv/loadenv.cxx @@ -344,19 +344,20 @@ void LoadEnv::initializeUIDefaults( const css::uno::Reference< css::uno::XCompon void LoadEnv::startLoading() { // SAFE -> - osl::ClearableMutexGuard aReadLock(m_mutex); - - // Handle still running processes! - if (m_xAsynchronousJob.is()) - throw LoadEnvException(LoadEnvException::ID_STILL_RUNNING); + { + osl::MutexGuard aReadLock(m_mutex); - // content can not be loaded or handled - // check "classifyContent()" failed before ... - if (m_eContentType == E_UNSUPPORTED_CONTENT) - throw LoadEnvException(LoadEnvException::ID_UNSUPPORTED_CONTENT, "from LoadEnv::startLoading"); + // Handle still running processes! + if (m_xAsynchronousJob.is()) + throw LoadEnvException(LoadEnvException::ID_STILL_RUNNING); + // content can not be loaded or handled + // check "classifyContent()" failed before ... + if (m_eContentType == E_UNSUPPORTED_CONTENT) + throw LoadEnvException(LoadEnvException::ID_UNSUPPORTED_CONTENT, + "from LoadEnv::startLoading"); + } // <- SAFE - aReadLock.clear(); // detect its type/filter etc. // These information will be available by the @@ -406,10 +407,11 @@ bool LoadEnv::waitWhileLoading(sal_uInt32 nTimeout) while(true) { // SAFE -> ------------------------------ - osl::ClearableMutexGuard aReadLock1(m_mutex); - if (!m_xAsynchronousJob.is()) - break; - aReadLock1.clear(); + { + osl::MutexGuard aReadLock1(m_mutex); + if (!m_xAsynchronousJob.is()) + break; + } // <- SAFE ------------------------------ Application::Yield(); @@ -1520,14 +1522,15 @@ css::uno::Reference< css::frame::XFrame > LoadEnv::impl_searchRecycleTarget() } // SAFE -> .................................. - osl::ClearableMutexGuard aWriteLock(m_mutex); + { + osl::MutexGuard aWriteLock(m_mutex); - css::uno::Reference< css::document::XActionLockable > xLock(xTask, css::uno::UNO_QUERY); - if (!m_aTargetLock.setResource(xLock)) - return css::uno::Reference< css::frame::XFrame >(); + css::uno::Reference< css::document::XActionLockable > xLock(xTask, css::uno::UNO_QUERY); + if (!m_aTargetLock.setResource(xLock)) + return css::uno::Reference< css::frame::XFrame >(); - m_bReactivateControllerOnError = bReactivateOldControllerOnError; - aWriteLock.clear(); + m_bReactivateControllerOnError = bReactivateOldControllerOnError; + } // <- SAFE .................................. // bring it to front ... @@ -1705,24 +1708,24 @@ void LoadEnv::impl_applyPersistentWindowState(const css::uno::Reference< css::aw return; // SOLAR SAFE -> - SolarMutexClearableGuard aSolarGuard1; - - VclPtr<vcl::Window> pWindow = VCLUnoHelper::GetWindow(xWindow); - if (!pWindow) - return; + { + SolarMutexGuard aSolarGuard1; - bool bSystemWindow = pWindow->IsSystemWindow(); - bool bWorkWindow = (pWindow->GetType() == WindowType::WORKWINDOW); + VclPtr<vcl::Window> pWindow = VCLUnoHelper::GetWindow(xWindow); + if (!pWindow) + return; - if (!bSystemWindow && !bWorkWindow) - return; + bool bSystemWindow = pWindow->IsSystemWindow(); + bool bWorkWindow = (pWindow->GetType() == WindowType::WORKWINDOW); - // don't overwrite this special state! - WorkWindow* pWorkWindow = static_cast<WorkWindow*>(pWindow.get()); - if (pWorkWindow->IsMinimized()) - return; + if (!bSystemWindow && !bWorkWindow) + return; - aSolarGuard1.clear(); + // don't overwrite this special state! + WorkWindow* pWorkWindow = static_cast<WorkWindow*>(pWindow.get()); + if (pWorkWindow->IsMinimized()) + return; + } // <- SOLAR SAFE // SAFE -> diff --git a/framework/source/services/autorecovery.cxx b/framework/source/services/autorecovery.cxx index c3c7735afeaf..3f6098efef69 100644 --- a/framework/source/services/autorecovery.cxx +++ b/framework/source/services/autorecovery.cxx @@ -1605,7 +1605,7 @@ void SAL_CALL AutoRecovery::changesOccurred(const css::util::ChangesEvent& aEven sal_Int32 i = 0; /* SAFE */ { - osl::ResettableMutexGuard g(cppu::WeakComponentImplHelperBase::rBHelper.rMutex); + osl::MutexGuard g(cppu::WeakComponentImplHelperBase::rBHelper.rMutex); // Changes of the configuration must be ignored if AutoSave/Recovery was disabled for this // office session. That can happen if e.g. the command line arguments "--norestore" or "--headless" diff --git a/framework/source/services/desktop.cxx b/framework/source/services/desktop.cxx index 7c3823e09f06..964ca410945f 100644 --- a/framework/source/services/desktop.cxx +++ b/framework/source/services/desktop.cxx @@ -1068,18 +1068,18 @@ void SAL_CALL Desktop::disposing() // tests for instance in sc/qa/unit) nothing bad happens. SAL_WARN_IF( !m_bIsTerminated, "fwk.desktop", "Desktop disposed before terminating it" ); - SolarMutexClearableGuard aWriteLock; - { - TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS ); - } + SolarMutexGuard aWriteLock; - // Disable this instance for further work. - // This will wait for all current running transactions ... - // and reject all new incoming requests! - m_aTransactionManager.setWorkingMode( E_BEFORECLOSE ); + { + TransactionGuard aTransaction(m_aTransactionManager, E_HARDEXCEPTIONS); + } - aWriteLock.clear(); + // Disable this instance for further work. + // This will wait for all current running transactions ... + // and reject all new incoming requests! + m_aTransactionManager.setWorkingMode(E_BEFORECLOSE); + } // Following lines of code can be called outside a synchronized block ... // Because our transaction manager will block all new requests to this object. diff --git a/framework/source/services/dispatchhelper.cxx b/framework/source/services/dispatchhelper.cxx index 27455004831d..ef534a9f67ba 100644 --- a/framework/source/services/dispatchhelper.cxx +++ b/framework/source/services/dispatchhelper.cxx @@ -139,10 +139,11 @@ DispatchHelper::executeDispatch(const css::uno::Reference<css::frame::XDispatch> css::uno::Reference<css::frame::XDispatchResultListener> xListener(xTHIS, css::uno::UNO_QUERY); /* SAFE { */ - osl::ClearableMutexGuard aWriteLock(m_mutex); - m_xBroadcaster.set(xNotifyDispatch, css::uno::UNO_QUERY); - m_aBlock.reset(); - aWriteLock.clear(); + { + osl::MutexGuard aWriteLock(m_mutex); + m_xBroadcaster.set(xNotifyDispatch, css::uno::UNO_QUERY); + m_aBlock.reset(); + } /* } SAFE */ // dispatch it and wait for a notification diff --git a/framework/source/services/frame.cxx b/framework/source/services/frame.cxx index 76673d41718f..2396ac9db8a0 100644 --- a/framework/source/services/frame.cxx +++ b/framework/source/services/frame.cxx @@ -869,7 +869,7 @@ void SAL_CALL XFrameImpl::setCreator( const css::uno::Reference< css::frame::XFr /* SAFE { */ { - SolarMutexClearableGuard aWriteLock; + SolarMutexGuard aWriteLock; m_xParent = xCreator; } /* } SAFE */ @@ -1479,9 +1479,10 @@ sal_Bool SAL_CALL XFrameImpl::setComponent(const css::uno::Reference< css::awt:: // Before we dispose this controller we should hide it inside this frame instance. // We hold it alive for next calls by using xOldController! /* SAFE {*/ - SolarMutexClearableGuard aWriteLock; - m_xController = nullptr; - aWriteLock.clear(); + { + SolarMutexGuard aWriteLock; + m_xController = nullptr; + } /* } SAFE */ css::uno::Reference< css::lang::XComponent > xDisposable( xOldController, css::uno::UNO_QUERY ); @@ -1508,9 +1509,10 @@ sal_Bool SAL_CALL XFrameImpl::setComponent(const css::uno::Reference< css::awt:: ) { /* SAFE { */ - SolarMutexClearableGuard aWriteLock; - m_xComponentWindow = nullptr; - aWriteLock.clear(); + { + SolarMutexGuard aWriteLock; + m_xComponentWindow = nullptr; + } /* } SAFE */ css::uno::Reference< css::lang::XComponent > xDisposable( xOldComponentWindow, css::uno::UNO_QUERY ); @@ -1718,9 +1720,10 @@ void SAL_CALL XFrameImpl::close( sal_Bool bDeliverOwnership ) } /* SAFE { */ - SolarMutexClearableGuard aWriteLock; - m_bIsHidden = true; - aWriteLock.clear(); + { + SolarMutexGuard aWriteLock; + m_bIsHidden = true; + } /* } SAFE */ impl_checkMenuCloser(); @@ -1899,7 +1902,7 @@ css::uno::Any SAL_CALL XFrameImpl::getPropertyValue(const OUString& sProperty) checkDisposed(); // SAFE -> - SolarMutexClearableGuard aReadLock; + SolarMutexGuard aReadLock; TPropInfoHash::const_iterator pIt = m_lProps.find(sProperty); if (pIt == m_lProps.end()) @@ -1917,13 +1920,13 @@ void SAL_CALL XFrameImpl::addPropertyChangeListener( checkDisposed(); // SAFE -> - SolarMutexClearableGuard aReadLock; - - TPropInfoHash::const_iterator pIt = m_lProps.find(sProperty); - if (pIt == m_lProps.end()) - throw css::beans::UnknownPropertyException(); + { + SolarMutexGuard aReadLock; - aReadLock.clear(); + TPropInfoHash::const_iterator pIt = m_lProps.find(sProperty); + if (pIt == m_lProps.end()) + throw css::beans::UnknownPropertyException(); + } // <- SAFE m_lSimpleChangeListener.addInterface(sProperty, xListener); @@ -1934,13 +1937,13 @@ void SAL_CALL XFrameImpl::removePropertyChangeListener( const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener) { // SAFE -> - SolarMutexClearableGuard aReadLock; - - TPropInfoHash::const_iterator pIt = m_lProps.find(sProperty); - if (pIt == m_lProps.end()) - throw css::beans::UnknownPropertyException(); + { + SolarMutexGuard aReadLock; - aReadLock.clear(); + TPropInfoHash::const_iterator pIt = m_lProps.find(sProperty); + if (pIt == m_lProps.end()) + throw css::beans::UnknownPropertyException(); + } // <- SAFE m_lSimpleChangeListener.removeInterface(sProperty, xListener); @@ -1953,13 +1956,13 @@ void SAL_CALL XFrameImpl::addVetoableChangeListener( checkDisposed(); // SAFE -> - SolarMutexClearableGuard aReadLock; - - TPropInfoHash::const_iterator pIt = m_lProps.find(sProperty); - if (pIt == m_lProps.end()) - throw css::beans::UnknownPropertyException(); + { + SolarMutexGuard aReadLock; - aReadLock.clear(); + TPropInfoHash::const_iterator pIt = m_lProps.find(sProperty); + if (pIt == m_lProps.end()) + throw css::beans::UnknownPropertyException(); + } // <- SAFE m_lVetoChangeListener.addInterface(sProperty, xListener); @@ -1970,13 +1973,13 @@ void SAL_CALL XFrameImpl::removeVetoableChangeListener( const css::uno::Reference< css::beans::XVetoableChangeListener >& xListener) { // SAFE -> - SolarMutexClearableGuard aReadLock; - - TPropInfoHash::const_iterator pIt = m_lProps.find(sProperty); - if (pIt == m_lProps.end()) - throw css::beans::UnknownPropertyException(); + { + SolarMutexGuard aReadLock; - aReadLock.clear(); + TPropInfoHash::const_iterator pIt = m_lProps.find(sProperty); + if (pIt == m_lProps.end()) + throw css::beans::UnknownPropertyException(); + } // <- SAFE m_lVetoChangeListener.removeInterface(sProperty, xListener); @@ -2616,9 +2619,10 @@ void SAL_CALL XFrameImpl::windowShown( const css::lang::EventObject& ) void SAL_CALL XFrameImpl::windowHidden( const css::lang::EventObject& ) { /* SAFE { */ - SolarMutexClearableGuard aReadLock; - m_bIsHidden = true; - aReadLock.clear(); + { + SolarMutexGuard aReadLock; + m_bIsHidden = true; + } /* } SAFE */ impl_checkMenuCloser(); diff --git a/framework/source/tabwin/tabwindow.cxx b/framework/source/tabwin/tabwindow.cxx index 4dd6bcc0bb0d..2bd9f27750bf 100644 --- a/framework/source/tabwin/tabwindow.cxx +++ b/framework/source/tabwin/tabwindow.cxx @@ -452,10 +452,11 @@ void SAL_CALL TabWindow::dispose() void SAL_CALL TabWindow::addEventListener( const css::uno::Reference< css::lang::XEventListener >& xListener ) { /* SAFE AREA ----------------------------------------------------------------------------------------------- */ - SolarMutexClearableGuard aLock; - if ( m_bDisposed ) - return; - aLock.clear(); + { + SolarMutexGuard aLock; + if (m_bDisposed) + return; + } /* SAFE AREA ----------------------------------------------------------------------------------------------- */ m_aListenerContainer.addInterface( cppu::UnoType<css::lang::XEventListener>::get(), xListener ); @@ -464,10 +465,11 @@ void SAL_CALL TabWindow::addEventListener( const css::uno::Reference< css::lang: void SAL_CALL TabWindow::removeEventListener( const css::uno::Reference< css::lang::XEventListener >& xListener ) { /* SAFE AREA ----------------------------------------------------------------------------------------------- */ - SolarMutexClearableGuard aLock; - if ( m_bDisposed ) - return; - aLock.clear(); + { + SolarMutexGuard aLock; + if (m_bDisposed) + return; + } /* SAFE AREA ----------------------------------------------------------------------------------------------- */ m_aListenerContainer.removeInterface( cppu::UnoType<css::lang::XEventListener>::get(), xListener ); @@ -732,10 +734,11 @@ void SAL_CALL TabWindow::addTabListener( const css::uno::Reference< css::awt::XTabListener >& xListener ) { /* SAFE AREA ----------------------------------------------------------------------------------------------- */ - SolarMutexClearableGuard aLock; - if ( m_bDisposed ) - return; - aLock.clear(); + { + SolarMutexGuard aLock; + if (m_bDisposed) + return; + } /* SAFE AREA ----------------------------------------------------------------------------------------------- */ m_aListenerContainer.addInterface( @@ -745,10 +748,11 @@ void SAL_CALL TabWindow::addTabListener( void SAL_CALL TabWindow::removeTabListener( const css::uno::Reference< css::awt::XTabListener >& xListener ) { /* SAFE AREA ----------------------------------------------------------------------------------------------- */ - SolarMutexClearableGuard aLock; - if ( m_bDisposed ) - return; - aLock.clear(); + { + SolarMutexGuard aLock; + if (m_bDisposed) + return; + } /* SAFE AREA ----------------------------------------------------------------------------------------------- */ m_aListenerContainer.removeInterface( diff --git a/framework/source/uiconfiguration/windowstateconfiguration.cxx b/framework/source/uiconfiguration/windowstateconfiguration.cxx index 65f0835de741..e2c62bc2caba 100644 --- a/framework/source/uiconfiguration/windowstateconfiguration.cxx +++ b/framework/source/uiconfiguration/windowstateconfiguration.cxx @@ -321,7 +321,7 @@ sal_Bool SAL_CALL ConfigurationAccess_WindowState::hasElements() void SAL_CALL ConfigurationAccess_WindowState::removeByName( const OUString& rResourceURL ) { // SAFE - osl::ResettableMutexGuard g(m_aMutex); + osl::ClearableMutexGuard g(m_aMutex); ResourceURLToInfoCache::iterator pIter = m_aResourceURLToInfoCache.find( rResourceURL ); if ( pIter != m_aResourceURLToInfoCache.end() ) @@ -355,7 +355,7 @@ void SAL_CALL ConfigurationAccess_WindowState::removeByName( const OUString& rRe void SAL_CALL ConfigurationAccess_WindowState::insertByName( const OUString& rResourceURL, const css::uno::Any& aPropertySet ) { // SAFE - osl::ResettableMutexGuard g(m_aMutex); + osl::ClearableMutexGuard g(m_aMutex); Sequence< PropertyValue > aPropSet; if ( !(aPropertySet >>= aPropSet) ) @@ -413,7 +413,7 @@ void SAL_CALL ConfigurationAccess_WindowState::insertByName( const OUString& rRe void SAL_CALL ConfigurationAccess_WindowState::replaceByName( const OUString& rResourceURL, const css::uno::Any& aPropertySet ) { // SAFE - osl::ResettableMutexGuard g(m_aMutex); + osl::ClearableMutexGuard g(m_aMutex); Sequence< PropertyValue > aPropSet; if ( !(aPropertySet >>= aPropSet) ) diff --git a/framework/source/uielement/controlmenucontroller.cxx b/framework/source/uielement/controlmenucontroller.cxx index 62b1dcf9047a..c4f8a8b33877 100644 --- a/framework/source/uielement/controlmenucontroller.cxx +++ b/framework/source/uielement/controlmenucontroller.cxx @@ -211,7 +211,7 @@ void SAL_CALL ControlMenuController::disposing( const EventObject& ) { Reference< css::awt::XMenuListener > xHolder(static_cast<OWeakObject *>(this), UNO_QUERY ); - osl::ResettableMutexGuard aLock( m_aMutex ); + osl::MutexGuard aLock( m_aMutex ); m_xFrame.clear(); m_xDispatch.clear(); @@ -225,7 +225,7 @@ void SAL_CALL ControlMenuController::disposing( const EventObject& ) // XStatusListener void SAL_CALL ControlMenuController::statusChanged( const FeatureStateEvent& Event ) { - osl::ResettableMutexGuard aLock( m_aMutex ); + osl::MutexGuard aLock( m_aMutex ); OString sIdent; for (size_t i=0; i < SAL_N_ELEMENTS(aCommands); ++i) @@ -285,7 +285,7 @@ void SAL_CALL ControlMenuController::statusChanged( const FeatureStateEvent& Eve // XMenuListener void SAL_CALL ControlMenuController::itemActivated( const css::awt::MenuEvent& ) { - osl::ResettableMutexGuard aLock( m_aMutex ); + osl::MutexGuard aLock( m_aMutex ); if ( m_xPopupMenu.is() ) { @@ -323,7 +323,7 @@ void ControlMenuController::impl_setPopupMenu() void SAL_CALL ControlMenuController::updatePopupMenu() { - osl::ResettableMutexGuard aLock( m_aMutex ); + osl::MutexGuard aLock( m_aMutex ); throwIfDisposed(); @@ -353,7 +353,7 @@ void SAL_CALL ControlMenuController::updatePopupMenu() // XInitialization void SAL_CALL ControlMenuController::initialize( const Sequence< Any >& aArguments ) { - osl::ResettableMutexGuard aLock( m_aMutex ); + osl::MutexGuard aLock( m_aMutex ); svt::PopupMenuControllerBase::initialize(aArguments); m_aBaseURL.clear(); } diff --git a/framework/source/uielement/newmenucontroller.cxx b/framework/source/uielement/newmenucontroller.cxx index 1e75ddee652b..e3e2ebd71d90 100644 --- a/framework/source/uielement/newmenucontroller.cxx +++ b/framework/source/uielement/newmenucontroller.cxx @@ -392,10 +392,11 @@ void SAL_CALL NewMenuController::itemSelected( const css::awt::MenuEvent& rEvent Reference< css::awt::XPopupMenu > xPopupMenu; Reference< XComponentContext > xContext; - osl::ClearableMutexGuard aLock( m_aMutex ); - xPopupMenu = m_xPopupMenu; - xContext = m_xContext; - aLock.clear(); + { + osl::MutexGuard aLock(m_aMutex); + xPopupMenu = m_xPopupMenu; + xContext = m_xContext; + } if ( xPopupMenu.is() ) { diff --git a/framework/source/uielement/recentfilesmenucontroller.cxx b/framework/source/uielement/recentfilesmenucontroller.cxx index 14172000e8ae..04042fa70f80 100644 --- a/framework/source/uielement/recentfilesmenucontroller.cxx +++ b/framework/source/uielement/recentfilesmenucontroller.cxx @@ -283,9 +283,10 @@ void SAL_CALL RecentFilesMenuController::itemSelected( const css::awt::MenuEvent { Reference< css::awt::XPopupMenu > xPopupMenu; - osl::ClearableMutexGuard aLock( m_aMutex ); - xPopupMenu = m_xPopupMenu; - aLock.clear(); + { + osl::MutexGuard aLock(m_aMutex); + xPopupMenu = m_xPopupMenu; + } if ( xPopupMenu.is() ) { diff --git a/framework/source/uielement/toolbarmodemenucontroller.cxx b/framework/source/uielement/toolbarmodemenucontroller.cxx index e0ff9f385682..9a683d5ba95a 100644 --- a/framework/source/uielement/toolbarmodemenucontroller.cxx +++ b/framework/source/uielement/toolbarmodemenucontroller.cxx @@ -223,11 +223,12 @@ void SAL_CALL ToolbarModeMenuController::itemSelected( const css::awt::MenuEvent Reference< XURLTransformer > xURLTransformer; Reference< XFrame > xFrame; - osl::ClearableMutexGuard aLock( m_aMutex ); - xPopupMenu = m_xPopupMenu; - xURLTransformer = m_xURLTransformer; - xFrame = m_xFrame; - aLock.clear(); + { + osl::MutexGuard aLock(m_aMutex); + xPopupMenu = m_xPopupMenu; + xURLTransformer = m_xURLTransformer; + xFrame = m_xFrame; + } if ( xPopupMenu.is() ) { diff --git a/framework/source/uielement/toolbarsmenucontroller.cxx b/framework/source/uielement/toolbarsmenucontroller.cxx index a0e7ec353a0c..4d066d5e5426 100644 --- a/framework/source/uielement/toolbarsmenucontroller.cxx +++ b/framework/source/uielement/toolbarsmenucontroller.cxx @@ -541,13 +541,14 @@ void SAL_CALL ToolbarsMenuController::itemSelected( const css::awt::MenuEvent& r Reference< XFrame > xFrame; Reference< XNameAccess > xPersistentWindowState; - osl::ClearableMutexGuard aLock( m_aMutex ); - xPopupMenu = m_xPopupMenu; - xContext = m_xContext; - xURLTransformer = m_xURLTransformer; - xFrame = m_xFrame; - xPersistentWindowState = m_xPersistentWindowState; - aLock.clear(); + { + osl::MutexGuard aLock(m_aMutex); + xPopupMenu = m_xPopupMenu; + xContext = m_xContext; + xURLTransformer = m_xURLTransformer; + xFrame = m_xFrame; + xPersistentWindowState = m_xPersistentWindowState; + } if ( xPopupMenu.is() ) { diff --git a/include/comphelper/componentbase.hxx b/include/comphelper/componentbase.hxx index 3d785087b87a..ce6353be40be 100644 --- a/include/comphelper/componentbase.hxx +++ b/include/comphelper/componentbase.hxx @@ -127,7 +127,7 @@ namespace comphelper } private: - ::osl::ResettableMutexGuard m_aMutexGuard; + osl::ClearableMutexGuard m_aMutexGuard; }; diff --git a/package/source/xstor/ohierarchyholder.cxx b/package/source/xstor/ohierarchyholder.cxx index 26b63f806eae..20c613b8b8d2 100644 --- a/package/source/xstor/ohierarchyholder.cxx +++ b/package/source/xstor/ohierarchyholder.cxx @@ -261,15 +261,15 @@ void SAL_CALL OHierarchyElement_Impl::disposing( const lang::EventObject& Source { try { - ::osl::ClearableMutexGuard aGuard( m_aMutex ); - uno::Reference< embed::XExtendedStorageStream > xStream( Source.Source, uno::UNO_QUERY ); + { + osl::MutexGuard aGuard(m_aMutex); + uno::Reference< embed::XExtendedStorageStream > xStream(Source.Source, uno::UNO_QUERY); - m_aOpenStreams.erase(std::remove_if(m_aOpenStreams.begin(), m_aOpenStreams.end(), - [&xStream](const OWeakStorRefList_Impl::value_type& rxStorage) { + m_aOpenStreams.erase(std::remove_if(m_aOpenStreams.begin(), m_aOpenStreams.end(), + [&xStream](const OWeakStorRefList_Impl::value_type& rxStorage) { return !rxStorage.get().is() || rxStorage.get() == xStream; }), - m_aOpenStreams.end()); - - aGuard.clear(); + m_aOpenStreams.end()); + } TestForClosing(); } diff --git a/package/source/xstor/owriteablestream.cxx b/package/source/xstor/owriteablestream.cxx index 5f27ba5d7774..67f152075131 100644 --- a/package/source/xstor/owriteablestream.cxx +++ b/package/source/xstor/owriteablestream.cxx @@ -1783,7 +1783,7 @@ void OWriteStream::CopyToStreamInternally_Impl( const uno::Reference< io::XStrea } } -void OWriteStream::ModifyParentUnlockMutex_Impl( ::osl::ResettableMutexGuard& aGuard ) +void OWriteStream::ModifyParentUnlockMutex_Impl(osl::ClearableMutexGuard& aGuard) { if ( m_pImpl->m_pParent ) { @@ -2116,7 +2116,7 @@ uno::Reference< io::XOutputStream > SAL_CALL OWriteStream::getOutputStream() void SAL_CALL OWriteStream::writeBytes( const uno::Sequence< sal_Int8 >& aData ) { - ::osl::ResettableMutexGuard aGuard( m_pData->m_xSharedMutex->GetMutex() ); + osl::ClearableMutexGuard aGuard(m_pData->m_xSharedMutex->GetMutex()); // the write method makes initialization itself, since it depends from the aData length // NO CheckInitOnDemand()! @@ -2301,7 +2301,7 @@ sal_Int64 SAL_CALL OWriteStream::getLength() void SAL_CALL OWriteStream::truncate() { - ::osl::ResettableMutexGuard aGuard( m_pData->m_xSharedMutex->GetMutex() ); + osl::ClearableMutexGuard aGuard(m_pData->m_xSharedMutex->GetMutex()); CheckInitOnDemand(); @@ -2414,7 +2414,7 @@ void SAL_CALL OWriteStream::removeEventListener( void SAL_CALL OWriteStream::setEncryptionPassword( const OUString& aPass ) { - ::osl::ResettableMutexGuard aGuard( m_pData->m_xSharedMutex->GetMutex() ); + osl::ClearableMutexGuard aGuard(m_pData->m_xSharedMutex->GetMutex()); CheckInitOnDemand(); @@ -2433,7 +2433,7 @@ void SAL_CALL OWriteStream::setEncryptionPassword( const OUString& aPass ) void SAL_CALL OWriteStream::removeEncryption() { - ::osl::ResettableMutexGuard aGuard( m_pData->m_xSharedMutex->GetMutex() ); + osl::ClearableMutexGuard aGuard(m_pData->m_xSharedMutex->GetMutex()); CheckInitOnDemand(); @@ -2452,7 +2452,7 @@ void SAL_CALL OWriteStream::removeEncryption() void SAL_CALL OWriteStream::setEncryptionData( const uno::Sequence< beans::NamedValue >& aEncryptionData ) { - ::osl::ResettableMutexGuard aGuard( m_pData->m_xSharedMutex->GetMutex() ); + osl::ClearableMutexGuard aGuard(m_pData->m_xSharedMutex->GetMutex()); CheckInitOnDemand(); @@ -2471,7 +2471,7 @@ void SAL_CALL OWriteStream::setEncryptionData( const uno::Sequence< beans::Named sal_Bool SAL_CALL OWriteStream::hasEncryptionData() { - ::osl::ResettableMutexGuard aGuard( m_pData->m_xSharedMutex->GetMutex() ); + osl::ClearableMutexGuard aGuard(m_pData->m_xSharedMutex->GetMutex()); if (!m_pImpl) return false; @@ -2849,7 +2849,7 @@ uno::Reference< beans::XPropertySetInfo > SAL_CALL OWriteStream::getPropertySetI void SAL_CALL OWriteStream::setPropertyValue( const OUString& aPropertyName, const uno::Any& aValue ) { - ::osl::ResettableMutexGuard aGuard( m_pData->m_xSharedMutex->GetMutex() ); + osl::ClearableMutexGuard aGuard(m_pData->m_xSharedMutex->GetMutex()); if ( !m_pImpl ) { @@ -3142,7 +3142,7 @@ void SAL_CALL OWriteStream::commit() try { BroadcastTransaction( STOR_MESS_PRECOMMIT ); - ::osl::ResettableMutexGuard aGuard( m_pData->m_xSharedMutex->GetMutex() ); + osl::ClearableMutexGuard aGuard(m_pData->m_xSharedMutex->GetMutex()); if ( !m_pImpl ) { @@ -3199,42 +3199,42 @@ void SAL_CALL OWriteStream::revert() BroadcastTransaction( STOR_MESS_PREREVERT ); - ::osl::ResettableMutexGuard aGuard( m_pData->m_xSharedMutex->GetMutex() ); - - if ( !m_pImpl ) { - SAL_INFO("package.xstor", "Disposed!"); - throw lang::DisposedException(); - } + osl::MutexGuard aGuard(m_pData->m_xSharedMutex->GetMutex()); - try { - m_pImpl->Revert(); - } - catch( const io::IOException& rIOException ) - { - SAL_INFO("package.xstor", "Rethrow: " << rIOException); - throw; - } - catch( const embed::StorageWrappedTargetException& rStorageWrappedTargetException ) - { - SAL_INFO("package.xstor", "Rethrow: " << rStorageWrappedTargetException); - throw; - } - catch( const uno::RuntimeException& rRuntimeException ) - { - SAL_INFO("package.xstor", "Rethrow: " << rRuntimeException); - throw; - } - catch( const uno::Exception& ) - { - uno::Any aCaught( ::cppu::getCaughtException() ); - SAL_INFO("package.xstor", "Rethrow: " << exceptionToString(aCaught)); - throw embed::StorageWrappedTargetException( "Problems on revert!", - static_cast< ::cppu::OWeakObject* >( this ), - aCaught ); - } + if (!m_pImpl) + { + SAL_INFO("package.xstor", "Disposed!"); + throw lang::DisposedException(); + } - aGuard.clear(); + try { + m_pImpl->Revert(); + } + catch (const io::IOException& rIOException) + { + SAL_INFO("package.xstor", "Rethrow: " << rIOException); + throw; + } + catch (const embed::StorageWrappedTargetException& rStorageWrappedTargetException) + { + SAL_INFO("package.xstor", "Rethrow: " << rStorageWrappedTargetException); + throw; + } + catch (const uno::RuntimeException& rRuntimeException) + { + SAL_INFO("package.xstor", "Rethrow: " << rRuntimeException); + throw; + } + catch (const uno::Exception&) + { + uno::Any aCaught(::cppu::getCaughtException()); + SAL_INFO("package.xstor", "Rethrow: " << exceptionToString(aCaught)); + throw embed::StorageWrappedTargetException("Problems on revert!", + static_cast<::cppu::OWeakObject*>(this), + aCaught); + } + } BroadcastTransaction( STOR_MESS_REVERTED ); } diff --git a/package/source/xstor/owriteablestream.hxx b/package/source/xstor/owriteablestream.hxx index 7d7abf6647c3..629d679fdccf 100644 --- a/package/source/xstor/owriteablestream.hxx +++ b/package/source/xstor/owriteablestream.hxx @@ -257,7 +257,7 @@ protected: void CopyToStreamInternally_Impl( const css::uno::Reference< css::io::XStream >& xStream ); - void ModifyParentUnlockMutex_Impl( ::osl::ResettableMutexGuard& aGuard ); + void ModifyParentUnlockMutex_Impl(osl::ClearableMutexGuard& aGuard); void BroadcastTransaction( sal_Int8 nMessage ); diff --git a/package/source/xstor/xstorage.cxx b/package/source/xstor/xstorage.cxx index 1130c344ce51..20dff2794b63 100644 --- a/package/source/xstor/xstorage.cxx +++ b/package/source/xstor/xstorage.cxx @@ -2231,7 +2231,7 @@ void SAL_CALL OStorage::copyToStorage( const uno::Reference< embed::XStorage >& uno::Reference< io::XStream > SAL_CALL OStorage::openStreamElement( const OUString& aStreamName, sal_Int32 nOpenMode ) { - ::osl::ResettableMutexGuard aGuard( m_pData->m_xSharedMutex->GetMutex() ); + osl::ClearableMutexGuard aGuard(m_pData->m_xSharedMutex->GetMutex()); if ( !m_pImpl ) { @@ -2770,161 +2770,167 @@ sal_Bool SAL_CALL OStorage::isStorageElement( const OUString& aElementName ) void SAL_CALL OStorage::removeElement( const OUString& aElementName ) { - ::osl::ResettableMutexGuard aGuard( m_pData->m_xSharedMutex->GetMutex() ); - - if ( !m_pImpl ) { - SAL_INFO("package.xstor", THROW_WHERE "Disposed!"); - throw lang::DisposedException( THROW_WHERE ); - } + osl::MutexGuard aGuard(m_pData->m_xSharedMutex->GetMutex()); - if ( aElementName.isEmpty() || !::comphelper::OStorageHelper::IsValidZipEntryFileName( aElementName, false ) ) - throw lang::IllegalArgumentException( THROW_WHERE "Unexpected entry name syntax.", uno::Reference< uno::XInterface >(), 1 ); + if (!m_pImpl) + { + SAL_INFO("package.xstor", THROW_WHERE "Disposed!"); + throw lang::DisposedException(THROW_WHERE); + } - if ( m_pData->m_nStorageType == embed::StorageFormats::OFOPXML && aElementName == "_rels" ) - throw lang::IllegalArgumentException( THROW_WHERE, uno::Reference< uno::XInterface >(), 1 ); // TODO: unacceptable name + if (aElementName.isEmpty() + || !::comphelper::OStorageHelper::IsValidZipEntryFileName(aElementName, false)) + throw lang::IllegalArgumentException(THROW_WHERE "Unexpected entry name syntax.", + uno::Reference<uno::XInterface>(), 1); - if ( !( m_pImpl->m_nStorageMode & embed::ElementModes::WRITE ) ) - throw io::IOException( THROW_WHERE ); // TODO: access denied + if (m_pData->m_nStorageType == embed::StorageFormats::OFOPXML && aElementName == "_rels") + throw lang::IllegalArgumentException(THROW_WHERE, uno::Reference<uno::XInterface>(), + 1); // TODO: unacceptable name - try - { - SotElement_Impl* pElement = m_pImpl->FindElement( aElementName ); + if (!(m_pImpl->m_nStorageMode & embed::ElementModes::WRITE)) + throw io::IOException(THROW_WHERE); // TODO: access denied - if ( !pElement ) - throw container::NoSuchElementException( THROW_WHERE ); //??? + try + { + SotElement_Impl* pElement = m_pImpl->FindElement(aElementName); - m_pImpl->RemoveElement( pElement ); + if (!pElement) + throw container::NoSuchElementException(THROW_WHERE); //??? - m_pImpl->m_bIsModified = true; - m_pImpl->m_bBroadcastModified = true; - } - catch( const embed::InvalidStorageException& rInvalidStorageException ) - { - SAL_INFO("package.xstor", "Rethrow: " << rInvalidStorageException); - throw; - } - catch( const lang::IllegalArgumentException& rIllegalArgumentException ) - { - SAL_INFO("package.xstor", "Rethrow: " << rIllegalArgumentException); - throw; - } - catch( const container::NoSuchElementException& rNoSuchElementException ) - { - SAL_INFO("package.xstor", "Rethrow: " << rNoSuchElementException); - throw; - } - catch( const io::IOException& rIOException ) - { - SAL_INFO("package.xstor", "Rethrow: " << rIOException); - throw; - } - catch( const embed::StorageWrappedTargetException& rStorageWrappedTargetException ) - { - SAL_INFO("package.xstor", "Rethrow: " << rStorageWrappedTargetException); - throw; - } - catch( const uno::RuntimeException& rRuntimeException ) - { - SAL_INFO("package.xstor", "Rethrow: " << rRuntimeException); - throw; - } - catch( const uno::Exception& ) - { - uno::Any aCaught( ::cppu::getCaughtException() ); - SAL_INFO("package.xstor", "Rethrow: " << exceptionToString(aCaught)); + m_pImpl->RemoveElement(pElement); - throw embed::StorageWrappedTargetException( THROW_WHERE "Can't remove element!", - uno::Reference< io::XInputStream >(), - aCaught ); - } + m_pImpl->m_bIsModified = true; + m_pImpl->m_bBroadcastModified = true; + } + catch (const embed::InvalidStorageException& rInvalidStorageException) + { + SAL_INFO("package.xstor", "Rethrow: " << rInvalidStorageException); + throw; + } + catch (const lang::IllegalArgumentException& rIllegalArgumentException) + { + SAL_INFO("package.xstor", "Rethrow: " << rIllegalArgumentException); + throw; + } + catch (const container::NoSuchElementException& rNoSuchElementException) + { + SAL_INFO("package.xstor", "Rethrow: " << rNoSuchElementException); + throw; + } + catch (const io::IOException& rIOException) + { + SAL_INFO("package.xstor", "Rethrow: " << rIOException); + throw; + } + catch (const embed::StorageWrappedTargetException& rStorageWrappedTargetException) + { + SAL_INFO("package.xstor", "Rethrow: " << rStorageWrappedTargetException); + throw; + } + catch (const uno::RuntimeException& rRuntimeException) + { + SAL_INFO("package.xstor", "Rethrow: " << rRuntimeException); + throw; + } + catch (const uno::Exception&) + { + uno::Any aCaught(::cppu::getCaughtException()); + SAL_INFO("package.xstor", "Rethrow: " << exceptionToString(aCaught)); - aGuard.clear(); + throw embed::StorageWrappedTargetException(THROW_WHERE "Can't remove element!", + uno::Reference<io::XInputStream>(), aCaught); + } + } BroadcastModifiedIfNecessary(); } void SAL_CALL OStorage::renameElement( const OUString& aElementName, const OUString& aNewName ) { - ::osl::ResettableMutexGuard aGuard( m_pData->m_xSharedMutex->GetMutex() ); - - if ( !m_pImpl ) { - SAL_INFO("package.xstor", THROW_WHERE "Disposed!"); - throw lang::DisposedException( THROW_WHERE ); - } + osl::MutexGuard aGuard(m_pData->m_xSharedMutex->GetMutex()); - if ( aElementName.isEmpty() || !::comphelper::OStorageHelper::IsValidZipEntryFileName( aElementName, false ) - || aNewName.isEmpty() || !::comphelper::OStorageHelper::IsValidZipEntryFileName( aNewName, false ) ) - throw lang::IllegalArgumentException( THROW_WHERE "Unexpected entry name syntax.", uno::Reference< uno::XInterface >(), 1 ); + if (!m_pImpl) + { + SAL_INFO("package.xstor", THROW_WHERE "Disposed!"); + throw lang::DisposedException(THROW_WHERE); + } - if ( m_pData->m_nStorageType == embed::StorageFormats::OFOPXML && ( aElementName == "_rels" || aNewName == "_rels" ) ) - throw lang::IllegalArgumentException( THROW_WHERE, uno::Reference< uno::XInterface >(), 0 ); // TODO: unacceptable element name + if (aElementName.isEmpty() + || !::comphelper::OStorageHelper::IsValidZipEntryFileName(aElementName, false) + || aNewName.isEmpty() + || !::comphelper::OStorageHelper::IsValidZipEntryFileName(aNewName, false)) + throw lang::IllegalArgumentException(THROW_WHERE "Unexpected entry name syntax.", + uno::Reference<uno::XInterface>(), 1); - if ( !( m_pImpl->m_nStorageMode & embed::ElementModes::WRITE ) ) - throw io::IOException( THROW_WHERE ); // TODO: access denied + if (m_pData->m_nStorageType == embed::StorageFormats::OFOPXML + && (aElementName == "_rels" || aNewName == "_rels")) + throw lang::IllegalArgumentException(THROW_WHERE, uno::Reference<uno::XInterface>(), + 0); // TODO: unacceptable element name - try - { - SotElement_Impl* pRefElement = m_pImpl->FindElement( aNewName ); - if ( pRefElement ) - throw container::ElementExistException( THROW_WHERE ); //??? + if (!(m_pImpl->m_nStorageMode & embed::ElementModes::WRITE)) + throw io::IOException(THROW_WHERE); // TODO: access denied - SotElement_Impl* pElement = m_pImpl->FindElement( aElementName ); - if ( !pElement ) - throw container::NoSuchElementException( THROW_WHERE ); //??? + try + { + SotElement_Impl* pRefElement = m_pImpl->FindElement(aNewName); + if (pRefElement) + throw container::ElementExistException(THROW_WHERE); //??? - pElement->m_aName = aNewName; + SotElement_Impl* pElement = m_pImpl->FindElement(aElementName); + if (!pElement) + throw container::NoSuchElementException(THROW_WHERE); //??? - m_pImpl->m_bIsModified = true; - m_pImpl->m_bBroadcastModified = true; - } - catch( const embed::InvalidStorageException& rInvalidStorageException ) - { - SAL_INFO("package.xstor", "Rethrow: " << rInvalidStorageException); - throw; - } - catch( const lang::IllegalArgumentException& rIllegalArgumentException ) - { - SAL_INFO("package.xstor", "Rethrow: " << rIllegalArgumentException); - throw; - } - catch( const container::NoSuchElementException& rNoSuchElementException ) - { - SAL_INFO("package.xstor", "Rethrow: " << rNoSuchElementException); - throw; - } - catch( const container::ElementExistException& rElementExistException ) - { - SAL_INFO("package.xstor", "Rethrow: " << rElementExistException); - throw; - } - catch( const io::IOException& rIOException ) - { - SAL_INFO("package.xstor", "Rethrow: " << rIOException); - throw; - } - catch( const embed::StorageWrappedTargetException& rStorageWrappedTargetException ) - { - SAL_INFO("package.xstor", "Rethrow: " << rStorageWrappedTargetException); - throw; - } - catch( const uno::RuntimeException& rRuntimeException ) - { - SAL_INFO("package.xstor", "Rethrow: " << rRuntimeException); - throw; - } - catch( const uno::Exception& ) - { - uno::Any aCaught( ::cppu::getCaughtException() ); - SAL_INFO("package.xstor", "Rethrow: " << exceptionToString(aCaught)); + pElement->m_aName = aNewName; - throw embed::StorageWrappedTargetException( THROW_WHERE "Can't rename element!", - uno::Reference< io::XInputStream >(), - aCaught ); - } + m_pImpl->m_bIsModified = true; + m_pImpl->m_bBroadcastModified = true; + } + catch (const embed::InvalidStorageException& rInvalidStorageException) + { + SAL_INFO("package.xstor", "Rethrow: " << rInvalidStorageException); + throw; + } + catch (const lang::IllegalArgumentException& rIllegalArgumentException) + { + SAL_INFO("package.xstor", "Rethrow: " << rIllegalArgumentException); + throw; + } + catch (const container::NoSuchElementException& rNoSuchElementException) + { + SAL_INFO("package.xstor", "Rethrow: " << rNoSuchElementException); + throw; + } + catch (const container::ElementExistException& rElementExistException) + { + SAL_INFO("package.xstor", "Rethrow: " << rElementExistException); + throw; + } + catch (const io::IOException& rIOException) + { + SAL_INFO("package.xstor", "Rethrow: " << rIOException); + throw; + } + catch (const embed::StorageWrappedTargetException& rStorageWrappedTargetException) + { + SAL_INFO("package.xstor", "Rethrow: " << rStorageWrappedTargetException); + throw; + } + catch (const uno::RuntimeException& rRuntimeException) + { + SAL_INFO("package.xstor", "Rethrow: " << rRuntimeException); + throw; + } + catch (const uno::Exception&) + { + uno::Any aCaught(::cppu::getCaughtException()); + SAL_INFO("package.xstor", "Rethrow: " << exceptionToString(aCaught)); - aGuard.clear(); + throw embed::StorageWrappedTargetException(THROW_WHERE "Can't rename element!", + uno::Reference<io::XInputStream>(), aCaught); + } + } BroadcastModifiedIfNecessary(); } @@ -3014,90 +3020,97 @@ void SAL_CALL OStorage::moveElementTo( const OUString& aElementName, const uno::Reference< embed::XStorage >& xDest, const OUString& aNewName ) { - ::osl::ResettableMutexGuard aGuard( m_pData->m_xSharedMutex->GetMutex() ); - - if ( !m_pImpl ) { - SAL_INFO("package.xstor", THROW_WHERE "Disposed!"); - throw lang::DisposedException( THROW_WHERE ); - } + osl::MutexGuard aGuard(m_pData->m_xSharedMutex->GetMutex()); - if ( aElementName.isEmpty() || !::comphelper::OStorageHelper::IsValidZipEntryFileName( aElementName, false ) - || aNewName.isEmpty() || !::comphelper::OStorageHelper::IsValidZipEntryFileName( aNewName, false ) ) - throw lang::IllegalArgumentException( THROW_WHERE "Unexpected entry name syntax.", uno::Reference< uno::XInterface >(), 1 ); + if (!m_pImpl) + { + SAL_INFO("package.xstor", THROW_WHERE "Disposed!"); + throw lang::DisposedException(THROW_WHERE); + } - if ( !xDest.is() || xDest == uno::Reference< uno::XInterface >( static_cast< OWeakObject* >( this ), uno::UNO_QUERY ) ) - throw lang::IllegalArgumentException( THROW_WHERE, uno::Reference< uno::XInterface >(), 2 ); + if (aElementName.isEmpty() + || !::comphelper::OStorageHelper::IsValidZipEntryFileName(aElementName, false) + || aNewName.isEmpty() + || !::comphelper::OStorageHelper::IsValidZipEntryFileName(aNewName, false)) + throw lang::IllegalArgumentException(THROW_WHERE "Unexpected entry name syntax.", + uno::Reference<uno::XInterface>(), 1); - if ( m_pData->m_nStorageType == embed::StorageFormats::OFOPXML && ( aElementName == "_rels" || aNewName == "_rels" ) ) - throw lang::IllegalArgumentException( THROW_WHERE, uno::Reference< uno::XInterface >(), 0 ); // unacceptable element name + if (!xDest.is() + || xDest + == uno::Reference<uno::XInterface>(static_cast<OWeakObject*>(this), + uno::UNO_QUERY)) + throw lang::IllegalArgumentException(THROW_WHERE, uno::Reference<uno::XInterface>(), 2); - if ( !( m_pImpl->m_nStorageMode & embed::ElementModes::WRITE ) ) - throw io::IOException( THROW_WHERE ); // TODO: access denied + if (m_pData->m_nStorageType == embed::StorageFormats::OFOPXML + && (aElementName == "_rels" || aNewName == "_rels")) + throw lang::IllegalArgumentException(THROW_WHERE, uno::Reference<uno::XInterface>(), + 0); // unacceptable element name - try - { - SotElement_Impl* pElement = m_pImpl->FindElement( aElementName ); - if ( !pElement ) - throw container::NoSuchElementException( THROW_WHERE ); //??? + if (!(m_pImpl->m_nStorageMode & embed::ElementModes::WRITE)) + throw io::IOException(THROW_WHERE); // TODO: access denied - uno::Reference< XNameAccess > xNameAccess( xDest, uno::UNO_QUERY_THROW ); - if ( xNameAccess->hasByName( aNewName ) ) - throw container::ElementExistException( THROW_WHERE ); + try + { + SotElement_Impl* pElement = m_pImpl->FindElement(aElementName); + if (!pElement) + throw container::NoSuchElementException(THROW_WHERE); //??? - m_pImpl->CopyStorageElement( pElement, xDest, aNewName, false ); + uno::Reference<XNameAccess> xNameAccess(xDest, uno::UNO_QUERY_THROW); + if (xNameAccess->hasByName(aNewName)) + throw container::ElementExistException(THROW_WHERE); - m_pImpl->RemoveElement( pElement ); + m_pImpl->CopyStorageElement(pElement, xDest, aNewName, false); - m_pImpl->m_bIsModified = true; - m_pImpl->m_bBroadcastModified = true; - } - catch( const embed::InvalidStorageException& rInvalidStorageException ) - { - SAL_INFO("package.xstor", "Rethrow: " << rInvalidStorageException); - throw; - } - catch( const lang::IllegalArgumentException& rIllegalArgumentException ) - { - SAL_INFO("package.xstor", "Rethrow: " << rIllegalArgumentException); - throw; - } - catch( const container::NoSuchElementException& rNoSuchElementException ) - { - SAL_INFO("package.xstor", "Rethrow: " << rNoSuchElementException); - throw; - } - catch( const container::ElementExistException& rElementExistException ) - { - SAL_INFO("package.xstor", "Rethrow: " << rElementExistException); - throw; - } - catch( const embed::StorageWrappedTargetException& rStorageWrappedTargetException ) - { - SAL_INFO("package.xstor", "Rethrow: " << rStorageWrappedTargetException); - throw; - } - catch( const io::IOException& rIOException ) - { - SAL_INFO("package.xstor", "Rethrow: " << rIOException); - throw; - } - catch( const uno::RuntimeException& rRuntimeException ) - { - SAL_INFO("package.xstor", "Rethrow: " << rRuntimeException); - throw; - } - catch( const uno::Exception& ) - { - uno::Any aCaught( ::cppu::getCaughtException() ); - SAL_INFO("package.xstor", "Rethrow: " << exceptionToString(aCaught)); + m_pImpl->RemoveElement(pElement); - throw embed::StorageWrappedTargetException( THROW_WHERE "Can't move element!", - uno::Reference< io::XInputStream >(), - aCaught ); - } + m_pImpl->m_bIsModified = true; + m_pImpl->m_bBroadcastModified = true; + } + catch (const embed::InvalidStorageException& rInvalidStorageException) + { + SAL_INFO("package.xstor", "Rethrow: " << rInvalidStorageException); + throw; + } + catch (const lang::IllegalArgumentException& rIllegalArgumentException) + { + SAL_INFO("package.xstor", "Rethrow: " << rIllegalArgumentException); + throw; + } + catch (const container::NoSuchElementException& rNoSuchElementException) + { + SAL_INFO("package.xstor", "Rethrow: " << rNoSuchElementException); + throw; + } + catch (const container::ElementExistException& rElementExistException) + { + SAL_INFO("package.xstor", "Rethrow: " << rElementExistException); + throw; + } + catch (const embed::StorageWrappedTargetException& rStorageWrappedTargetException) + { + SAL_INFO("package.xstor", "Rethrow: " << rStorageWrappedTargetException); + throw; + } + catch (const io::IOException& rIOException) + { + SAL_INFO("package.xstor", "Rethrow: " << rIOException); + throw; + } + catch (const uno::RuntimeException& rRuntimeException) + { + SAL_INFO("package.xstor", "Rethrow: " << rRuntimeException); + throw; + } + catch (const uno::Exception&) + { + uno::Any aCaught(::cppu::getCaughtException()); + SAL_INFO("package.xstor", "Rethrow: " << exceptionToString(aCaught)); - aGuard.clear(); + throw embed::StorageWrappedTargetException(THROW_WHERE "Can't move element!", + uno::Reference<io::XInputStream>(), aCaught); + } + } BroadcastModifiedIfNecessary(); } @@ -3106,7 +3119,7 @@ void SAL_CALL OStorage::moveElementTo( const OUString& aElementName, uno::Reference< io::XStream > SAL_CALL OStorage::openEncryptedStream( const OUString& aStreamName, sal_Int32 nOpenMode, const uno::Sequence< beans::NamedValue >& aEncryptionData ) { - ::osl::ResettableMutexGuard aGuard( m_pData->m_xSharedMutex->GetMutex() ); + osl::ClearableMutexGuard aGuard( m_pData->m_xSharedMutex->GetMutex() ); if ( !m_pImpl ) { @@ -3589,57 +3602,63 @@ void SAL_CALL OStorage::revert() BroadcastTransaction( STOR_MESS_PREREVERT ); - ::osl::ResettableMutexGuard aGuard( m_pData->m_xSharedMutex->GetMutex() ); - - if ( !m_pImpl ) { - SAL_INFO("package.xstor", THROW_WHERE "Disposed!"); - throw lang::DisposedException( THROW_WHERE ); - } + osl::MutexGuard aGuard(m_pData->m_xSharedMutex->GetMutex()); - bool bThrow = std::any_of(m_pImpl->m_aChildrenVector.begin(), m_pImpl->m_aChildrenVector.end(), [](const SotElement_Impl* pElement) { - return (pElement->m_xStorage - && (pElement->m_xStorage->m_pAntiImpl || !pElement->m_xStorage->m_aReadOnlyWrapVector.empty())) - || (pElement->m_xStream - && (pElement->m_xStream->m_pAntiImpl || !pElement->m_xStream->m_aInputStreamsVector.empty())); }); - if (bThrow) - throw io::IOException( THROW_WHERE ); // TODO: access denied + if (!m_pImpl) + { + SAL_INFO("package.xstor", THROW_WHERE "Disposed!"); + throw lang::DisposedException(THROW_WHERE); + } - if ( m_pData->m_bReadOnlyWrap || !m_pImpl->m_bListCreated ) - return; // nothing to do + bool bThrow = std::any_of( + m_pImpl->m_aChildrenVector.begin(), m_pImpl->m_aChildrenVector.end(), + [](const SotElement_Impl* pElement) { + return (pElement->m_xStorage + && (pElement->m_xStorage->m_pAntiImpl + || !pElement->m_xStorage->m_aReadOnlyWrapVector.empty())) + || (pElement->m_xStream + && (pElement->m_xStream->m_pAntiImpl + || !pElement->m_xStream->m_aInputStreamsVector.empty())); + }); + if (bThrow) + throw io::IOException(THROW_WHERE); // TODO: access denied + + if (m_pData->m_bReadOnlyWrap || !m_pImpl->m_bListCreated) + return; // nothing to do - try { - m_pImpl->Revert(); - m_pImpl->m_bIsModified = false; - m_pImpl->m_bBroadcastModified = true; - } - catch( const io::IOException& rIOException ) - { - SAL_INFO("package.xstor", "Rethrow: " << rIOException); - throw; - } - catch( const embed::StorageWrappedTargetException& rStorageWrappedTargetException ) - { - SAL_INFO("package.xstor", "Rethrow: " << rStorageWrappedTargetException); - throw; - } - catch( const uno::RuntimeException& rRuntimeException ) - { - SAL_INFO("package.xstor", "Rethrow: " << rRuntimeException); - throw; - } - catch( const uno::Exception& ) - { - uno::Any aCaught( ::cppu::getCaughtException() ); - SAL_INFO("package.xstor", "Rethrow: " << exceptionToString(aCaught)); + try + { + m_pImpl->Revert(); + m_pImpl->m_bIsModified = false; + m_pImpl->m_bBroadcastModified = true; + } + catch (const io::IOException& rIOException) + { + SAL_INFO("package.xstor", "Rethrow: " << rIOException); + throw; + } + catch (const embed::StorageWrappedTargetException& rStorageWrappedTargetException) + { + SAL_INFO("package.xstor", "Rethrow: " << rStorageWrappedTargetException); + throw; + } + catch (const uno::RuntimeException& rRuntimeException) + { + SAL_INFO("package.xstor", "Rethrow: " << rRuntimeException); + throw; + } + catch (const uno::Exception&) + { + uno::Any aCaught(::cppu::getCaughtException()); + SAL_INFO("package.xstor", "Rethrow: " << exceptionToString(aCaught)); - throw embed::StorageWrappedTargetException( THROW_WHERE "Problems on revert!", - static_cast< ::cppu::OWeakObject* >( this ), - aCaught ); + throw embed::StorageWrappedTargetException(THROW_WHERE "Problems on revert!", + static_cast<::cppu::OWeakObject*>(this), + aCaught); + } } - aGuard.clear(); - setModified( false ); BroadcastTransaction( STOR_MESS_REVERTED ); } @@ -3693,21 +3712,22 @@ sal_Bool SAL_CALL OStorage::isModified() void SAL_CALL OStorage::setModified( sal_Bool bModified ) { - ::osl::ResettableMutexGuard aGuard( m_pData->m_xSharedMutex->GetMutex() ); - - if ( !m_pImpl ) { - SAL_INFO("package.xstor", THROW_WHERE "Disposed!"); - throw lang::DisposedException( THROW_WHERE ); - } + osl::MutexGuard aGuard(m_pData->m_xSharedMutex->GetMutex()); - if ( m_pData->m_bReadOnlyWrap ) - throw beans::PropertyVetoException( THROW_WHERE ); // TODO: access denied + if (!m_pImpl) + { + SAL_INFO("package.xstor", THROW_WHERE "Disposed!"); + throw lang::DisposedException(THROW_WHERE); + } - if ( m_pImpl->m_bIsModified != bool(bModified) ) - m_pImpl->m_bIsModified = bModified; + if (m_pData->m_bReadOnlyWrap) + throw beans::PropertyVetoException(THROW_WHERE); // TODO: access denied + + if (m_pImpl->m_bIsModified != bool(bModified)) + m_pImpl->m_bIsModified = bModified; + } - aGuard.clear(); if ( bModified ) { m_pImpl->m_bBroadcastModified = true; diff --git a/reportdesign/source/core/api/ReportDefinition.cxx b/reportdesign/source/core/api/ReportDefinition.cxx index 695334214042..7aad736fa96d 100644 --- a/reportdesign/source/core/api/ReportDefinition.cxx +++ b/reportdesign/source/core/api/ReportDefinition.cxx @@ -639,7 +639,7 @@ void SAL_CALL OReportDefinition::disposing() // SYNCHRONIZED ---> { SolarMutexGuard aSolarGuard; - ::osl::ResettableMutexGuard aGuard(m_aMutex); + osl::MutexGuard aGuard(m_aMutex); m_pImpl->m_aControllers.clear(); @@ -1732,7 +1732,7 @@ sal_Bool SAL_CALL OReportDefinition::isModified( ) void SAL_CALL OReportDefinition::setModified( sal_Bool _bModified ) { - ::osl::ResettableMutexGuard aGuard(m_aMutex); + osl::ClearableMutexGuard aGuard(m_aMutex); ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed); if ( !m_pImpl->m_bSetModifiedEnabled ) @@ -1773,7 +1773,7 @@ void OReportDefinition::notifyEvent(const OUString& _sEventName) { try { - ::osl::ResettableMutexGuard aGuard(m_aMutex); + osl::ClearableMutexGuard aGuard(m_aMutex); ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed); document::EventObject aEvt(*this, _sEventName); aGuard.clear(); @@ -1791,7 +1791,7 @@ void SAL_CALL OReportDefinition::notifyDocumentEvent( const OUString& rEventName { try { - ::osl::ResettableMutexGuard aGuard(m_aMutex); + osl::ClearableMutexGuard aGuard(m_aMutex); ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed); document::DocumentEvent aEvt(*this, rEventName, rViewController, rSupplement); aGuard.clear(); diff --git a/reportdesign/source/ui/inspection/DataProviderHandler.cxx b/reportdesign/source/ui/inspection/DataProviderHandler.cxx index cc01968c9dbc..f78f7a08a335 100644 --- a/reportdesign/source/ui/inspection/DataProviderHandler.cxx +++ b/reportdesign/source/ui/inspection/DataProviderHandler.cxx @@ -432,7 +432,7 @@ inspection::InteractiveSelectionResult SAL_CALL DataProviderHandler::onInteracti void SAL_CALL DataProviderHandler::actuatingPropertyChanged(const OUString & ActuatingPropertyName, const uno::Any & NewValue, const uno::Any & OldValue, const uno::Reference< inspection::XObjectInspectorUI > & InspectorUI, sal_Bool FirstTimeInit) { - ::osl::ClearableMutexGuard aGuard( m_aMutex ); + osl::MutexGuard aGuard( m_aMutex ); if ( ActuatingPropertyName == PROPERTY_COMMAND ) { diff --git a/reportdesign/source/ui/report/ReportControllerObserver.cxx b/reportdesign/source/ui/report/ReportControllerObserver.cxx index abcf21bb9771..d388239cb626 100644 --- a/reportdesign/source/ui/report/ReportControllerObserver.cxx +++ b/reportdesign/source/ui/report/ReportControllerObserver.cxx @@ -143,7 +143,7 @@ public: // XPropertyChangeListener void SAL_CALL OXReportControllerObserver::propertyChange(const beans::PropertyChangeEvent& _rEvent) { - ::osl::ClearableMutexGuard aGuard( m_pImpl->m_aMutex ); + osl::MutexGuard aGuard( m_pImpl->m_aMutex ); if ( m_pImpl->m_nLocks != 0 ) return; diff --git a/sax/source/fastparser/fastparser.cxx b/sax/source/fastparser/fastparser.cxx index 6d888f2d1115..92a5f7a87b38 100644 --- a/sax/source/fastparser/fastparser.cxx +++ b/sax/source/fastparser/fastparser.cxx @@ -508,7 +508,7 @@ EventList& Entity::getEventList() { if (!mxProducedEvents) { - osl::ResettableMutexGuard aGuard(maEventProtector); + osl::ClearableMutexGuard aGuard(maEventProtector); if (!maUsedEvents.empty()) { mxProducedEvents = std::move(maUsedEvents.front()); diff --git a/sd/source/core/stlsheet.cxx b/sd/source/core/stlsheet.cxx index 4e81c7304a5c..393160b81926 100644 --- a/sd/source/core/stlsheet.cxx +++ b/sd/source/core/stlsheet.cxx @@ -714,12 +714,13 @@ void SAL_CALL SdStyleSheet::release( ) throw () void SAL_CALL SdStyleSheet::dispose( ) { - ClearableMutexGuard aGuard( mrBHelper.rMutex ); - if (mrBHelper.bDisposed || mrBHelper.bInDispose) - return; + { + MutexGuard aGuard(mrBHelper.rMutex); + if (mrBHelper.bDisposed || mrBHelper.bInDispose) + return; - mrBHelper.bInDispose = true; - aGuard.clear(); + mrBHelper.bInDispose = true; + } try { // side effect: keeping a reference to this diff --git a/sd/source/ui/dlg/RemoteDialogClientBox.cxx b/sd/source/ui/dlg/RemoteDialogClientBox.cxx index 3e976b90c6dd..ad1355644a23 100644 --- a/sd/source/ui/dlg/RemoteDialogClientBox.cxx +++ b/sd/source/ui/dlg/RemoteDialogClientBox.cxx @@ -184,7 +184,7 @@ void ClientBox::selectEntry( const long nPos ) //It would be probably best to always use a copy of m_vEntries //and some other state variables from ClientBox for //the whole painting operation. See issue i86993 - ::osl::ClearableMutexGuard guard(m_entriesMutex); + osl::MutexGuard guard(m_entriesMutex); if ( m_bHasActive ) { @@ -230,8 +230,6 @@ void ClientBox::selectEntry( const long nPos ) m_bNeedsRecalc = true; Invalidate(); } - - guard.clear(); } void ClientBox::DrawRow(vcl::RenderContext& rRenderContext, const ::tools::Rectangle& rRect, const TClientBoxEntry& rEntry) @@ -583,21 +581,21 @@ void ClientBox::addEntry( const std::shared_ptr<ClientInfo>& pClientInfo ) TClientBoxEntry xEntry( new ClientBoxEntry( pClientInfo ) ); - ::osl::ClearableMutexGuard guard(m_entriesMutex); - if ( m_vEntries.empty() ) { - m_vEntries.push_back( xEntry ); - } - else - { - m_vEntries.insert( m_vEntries.begin()+nPos, xEntry ); - } - - //access to m_nActive must be guarded - if ( m_bHasActive && ( m_nActive >= nPos ) ) - m_nActive += 1; + osl::MutexGuard guard(m_entriesMutex); + if (m_vEntries.empty()) + { + m_vEntries.push_back(xEntry); + } + else + { + m_vEntries.insert(m_vEntries.begin() + nPos, xEntry); + } - guard.clear(); + //access to m_nActive must be guarded + if (m_bHasActive && (m_nActive >= nPos)) + m_nActive += 1; + } if ( IsReallyVisible() ) Invalidate(); diff --git a/sfx2/source/appl/preventduplicateinteraction.cxx b/sfx2/source/appl/preventduplicateinteraction.cxx index f9c38dd81132..3f34743891d3 100644 --- a/sfx2/source/appl/preventduplicateinteraction.cxx +++ b/sfx2/source/appl/preventduplicateinteraction.cxx @@ -41,20 +41,14 @@ PreventDuplicateInteraction::~PreventDuplicateInteraction() void PreventDuplicateInteraction::setHandler(const css::uno::Reference< css::task::XInteractionHandler >& xHandler) { // SAFE -> - ::osl::ResettableMutexGuard aLock(m_aLock); + osl::MutexGuard aLock(m_aLock); m_xWarningDialogsParent.reset(); m_xHandler = xHandler; - aLock.clear(); // <- SAFE } void PreventDuplicateInteraction::useDefaultUUIHandler() { - // SAFE -> - ::osl::ResettableMutexGuard aLock(m_aLock); - aLock.clear(); - // <- SAFE - //if we use the default handler, set the parent to a window belonging to this object so that the dialogs //don't block unrelated windows. m_xWarningDialogsParent.reset(new WarningDialogsParentScope(m_xContext)); @@ -62,9 +56,8 @@ void PreventDuplicateInteraction::useDefaultUUIHandler() m_xContext, m_xWarningDialogsParent->GetDialogParent()), css::uno::UNO_QUERY_THROW); // SAFE -> - aLock.reset(); + osl::MutexGuard aLock(m_aLock); m_xHandler = xHandler; - aLock.clear(); // <- SAFE } @@ -72,7 +65,7 @@ css::uno::Any SAL_CALL PreventDuplicateInteraction::queryInterface( const css::u { if ( aType.equals( cppu::UnoType<XInteractionHandler2>::get() ) ) { - ::osl::ResettableMutexGuard aLock(m_aLock); + osl::MutexGuard aLock(m_aLock); css::uno::Reference< css::task::XInteractionHandler2 > xHandler( m_xHandler, css::uno::UNO_QUERY ); if ( !xHandler.is() ) return css::uno::Any(); @@ -86,7 +79,7 @@ void SAL_CALL PreventDuplicateInteraction::handle(const css::uno::Reference< css bool bHandleIt = true; // SAFE -> - ::osl::ResettableMutexGuard aLock(m_aLock); + osl::ClearableMutexGuard aLock(m_aLock); auto pIt = std::find_if(m_lInteractionRules.begin(), m_lInteractionRules.end(), [&aRequest](const InteractionInfo& rInfo) { return aRequest.isExtractableTo(rInfo.m_aInteraction); }); @@ -131,7 +124,7 @@ sal_Bool SAL_CALL PreventDuplicateInteraction::handleInteractionRequest( const c bool bHandleIt = true; // SAFE -> - ::osl::ResettableMutexGuard aLock(m_aLock); + osl::ClearableMutexGuard aLock(m_aLock); auto pIt = std::find_if(m_lInteractionRules.begin(), m_lInteractionRules.end(), [&aRequest](const InteractionInfo& rInfo) { return aRequest.isExtractableTo(rInfo.m_aInteraction); }); @@ -176,7 +169,7 @@ sal_Bool SAL_CALL PreventDuplicateInteraction::handleInteractionRequest( const c void PreventDuplicateInteraction::addInteractionRule(const PreventDuplicateInteraction::InteractionInfo& aInteractionInfo) { // SAFE -> - ::osl::ResettableMutexGuard aLock(m_aLock); + osl::MutexGuard aLock(m_aLock); auto pIt = std::find_if(m_lInteractionRules.begin(), m_lInteractionRules.end(), [&aInteractionInfo](const InteractionInfo& rInfo) { return rInfo.m_aInteraction == aInteractionInfo.m_aInteraction; }); @@ -189,8 +182,6 @@ void PreventDuplicateInteraction::addInteractionRule(const PreventDuplicateInter } m_lInteractionRules.push_back(aInteractionInfo); - - aLock.clear(); // <- SAFE } @@ -198,7 +189,7 @@ bool PreventDuplicateInteraction::getInteractionInfo(const css::uno::Type& PreventDuplicateInteraction::InteractionInfo* pReturn ) const { // SAFE -> - ::osl::ResettableMutexGuard aLock(m_aLock); + osl::MutexGuard aLock(m_aLock); auto pIt = std::find_if(m_lInteractionRules.begin(), m_lInteractionRules.end(), [&aInteraction](const InteractionInfo& rInfo) { return rInfo.m_aInteraction == aInteraction; }); @@ -207,8 +198,6 @@ bool PreventDuplicateInteraction::getInteractionInfo(const css::uno::Type& *pReturn = *pIt; return true; } - - aLock.clear(); // <- SAFE return false; diff --git a/sfx2/source/appl/shutdownicon.cxx b/sfx2/source/appl/shutdownicon.cxx index b0e8792d8b37..6693dd5235f0 100644 --- a/sfx2/source/appl/shutdownicon.cxx +++ b/sfx2/source/appl/shutdownicon.cxx @@ -507,10 +507,8 @@ ShutdownIcon* ShutdownIcon::createInstance() void ShutdownIcon::init() { - ::osl::ResettableMutexGuard aGuard( m_aMutex ); - aGuard.clear(); css::uno::Reference < XDesktop2 > xDesktop = Desktop::create( m_xContext ); - aGuard.reset(); + osl::MutexGuard aGuard(m_aMutex); m_xDesktop = xDesktop; } @@ -534,7 +532,7 @@ void SAL_CALL ShutdownIcon::disposing( const css::lang::EventObject& ) void SAL_CALL ShutdownIcon::queryTermination( const css::lang::EventObject& ) { SAL_INFO("sfx.appl", "ShutdownIcon::queryTermination: veto is " << m_bVeto); - ::osl::ClearableMutexGuard aGuard( m_aMutex ); + osl::MutexGuard aGuard( m_aMutex ); if ( m_bVeto ) throw css::frame::TerminationVetoException(); diff --git a/sfx2/source/doc/SfxDocumentMetaData.cxx b/sfx2/source/doc/SfxDocumentMetaData.cxx index fff048706fad..43a3f2bbf4ff 100644 --- a/sfx2/source/doc/SfxDocumentMetaData.cxx +++ b/sfx2/source/doc/SfxDocumentMetaData.cxx @@ -1616,28 +1616,30 @@ void SAL_CALL SfxDocumentMetaData::setDocumentStatistics( const css::uno::Sequence< css::beans::NamedValue > & the_value) { - ::osl::ClearableMutexGuard g(m_aMutex); - checkInit(); - std::vector<std::pair<const char *, OUString> > attributes; - for (sal_Int32 i = 0; i < the_value.getLength(); ++i) { - const OUString name = the_value[i].Name; - // inefficiently search for matching attribute - for (size_t j = 0; s_stdStats[j] != nullptr; ++j) { - if (name.equalsAscii(s_stdStats[j])) { - const css::uno::Any any = the_value[i].Value; - sal_Int32 val = 0; - if (any >>= val) { - attributes.emplace_back(s_stdStatAttrs[j], - OUString::number(val)); - } else { - SAL_WARN("sfx.doc", "Invalid statistic: " << name); + { + osl::MutexGuard g(m_aMutex); + checkInit(); + std::vector<std::pair<const char *, OUString> > attributes; + for (sal_Int32 i = 0; i < the_value.getLength(); ++i) { + const OUString name = the_value[i].Name; + // inefficiently search for matching attribute + for (size_t j = 0; s_stdStats[j] != nullptr; ++j) { + if (name.equalsAscii(s_stdStats[j])) { + const css::uno::Any any = the_value[i].Value; + sal_Int32 val = 0; + if (any >>= val) { + attributes.emplace_back(s_stdStatAttrs[j], + OUString::number(val)); + } + else { + SAL_WARN("sfx.doc", "Invalid statistic: " << name); + } + break; } - break; } } + updateElement("meta:document-statistic", &attributes); } - updateElement("meta:document-statistic", &attributes); - g.clear(); setModified(true); } diff --git a/sfx2/source/doc/doctemplates.cxx b/sfx2/source/doc/doctemplates.cxx index 54adf06ba8b0..31f2a7e7951b 100644 --- a/sfx2/source/doc/doctemplates.cxx +++ b/sfx2/source/doc/doctemplates.cxx @@ -450,11 +450,10 @@ void SfxDocTplService_Impl::init_Impl() VclPtrInstance< WaitWindow_Impl > pWin; aSolarGuard.clear(); - ::osl::ClearableMutexGuard anotherGuard( maMutex ); - - update(); - - anotherGuard.clear(); + { + osl::MutexGuard anotherGuard(maMutex); + update(); + } SolarMutexGuard aSecondSolarGuard; pWin.disposeAndClear(); diff --git a/sfx2/source/inc/docundomanager.hxx b/sfx2/source/inc/docundomanager.hxx index 580a865c8a8f..ab713c1d50e2 100644 --- a/sfx2/source/inc/docundomanager.hxx +++ b/sfx2/source/inc/docundomanager.hxx @@ -90,7 +90,7 @@ public: } private: - SolarMutexResettableGuard m_aGuard; + SolarMutexClearableGuard m_aGuard; }; namespace sfx2 diff --git a/sfx2/source/notify/globalevents.cxx b/sfx2/source/notify/globalevents.cxx index 844fd7a676bd..6dd0340eb22d 100644 --- a/sfx2/source/notify/globalevents.cxx +++ b/sfx2/source/notify/globalevents.cxx @@ -152,7 +152,7 @@ SfxGlobalEvents_Impl::SfxGlobalEvents_Impl( const uno::Reference < uno::XCompone uno::Reference< container::XNameReplace > SAL_CALL SfxGlobalEvents_Impl::getEvents() { // SAFE -> - ::osl::ResettableMutexGuard aLock(m_aLock); + osl::MutexGuard aLock(m_aLock); return m_xEvents; // <- SAFE } @@ -214,11 +214,10 @@ void SAL_CALL SfxGlobalEvents_Impl::disposing(const lang::EventObject& aEvent) uno::Reference< frame::XModel > xDoc(aEvent.Source, uno::UNO_QUERY); // SAFE -> - ::osl::ResettableMutexGuard aLock(m_aLock); + osl::MutexGuard aLock(m_aLock); TModelList::iterator pIt = impl_searchDoc(xDoc); if (pIt != m_lModels.end()) m_lModels.erase(pIt); - aLock.clear(); // <- SAFE } @@ -231,11 +230,10 @@ sal_Bool SAL_CALL SfxGlobalEvents_Impl::has(const uno::Any& aElement) bool bHas = false; // SAFE -> - ::osl::ResettableMutexGuard aLock(m_aLock); + osl::MutexGuard aLock(m_aLock); TModelList::iterator pIt = impl_searchDoc(xDoc); if (pIt != m_lModels.end()) bHas = true; - aLock.clear(); // <- SAFE return bHas; @@ -253,14 +251,15 @@ void SAL_CALL SfxGlobalEvents_Impl::insert( const uno::Any& aElement ) 0); // SAFE -> - ::osl::ResettableMutexGuard aLock(m_aLock); - TModelList::iterator pIt = impl_searchDoc(xDoc); - if (pIt != m_lModels.end()) - throw container::ElementExistException( + { + osl::MutexGuard aLock(m_aLock); + TModelList::iterator pIt = impl_searchDoc(xDoc); + if (pIt != m_lModels.end()) + throw container::ElementExistException( OUString(), - static_cast< container::XSet* >(this)); - m_lModels.push_back(xDoc); - aLock.clear(); + static_cast<container::XSet*>(this)); + m_lModels.push_back(xDoc); + } // <- SAFE uno::Reference< document::XDocumentEventBroadcaster > xDocBroadcaster(xDoc, uno::UNO_QUERY ); @@ -287,14 +286,15 @@ void SAL_CALL SfxGlobalEvents_Impl::remove( const uno::Any& aElement ) 0); // SAFE -> - ::osl::ResettableMutexGuard aLock(m_aLock); - TModelList::iterator pIt = impl_searchDoc(xDoc); - if (pIt == m_lModels.end()) - throw container::NoSuchElementException( + { + osl::MutexGuard aLock(m_aLock); + TModelList::iterator pIt = impl_searchDoc(xDoc); + if (pIt == m_lModels.end()) + throw container::NoSuchElementException( OUString(), - static_cast< container::XSet* >(this)); - m_lModels.erase(pIt); - aLock.clear(); + static_cast<container::XSet*>(this)); + m_lModels.erase(pIt); + } // <- SAFE uno::Reference< document::XDocumentEventBroadcaster > xDocBroadcaster(xDoc, uno::UNO_QUERY ); @@ -313,14 +313,13 @@ void SAL_CALL SfxGlobalEvents_Impl::remove( const uno::Any& aElement ) uno::Reference< container::XEnumeration > SAL_CALL SfxGlobalEvents_Impl::createEnumeration() { // SAFE -> - ::osl::ResettableMutexGuard aLock(m_aLock); + osl::MutexGuard aLock(m_aLock); uno::Sequence<uno::Any> models(m_lModels.size()); for (size_t i = 0; i < m_lModels.size(); ++i) { models[i] <<= m_lModels[i]; } uno::Reference<container::XEnumeration> xEnum(new ::comphelper::OAnyEnumeration(models)); - aLock.clear(); // <- SAFE return xEnum; @@ -336,7 +335,7 @@ uno::Type SAL_CALL SfxGlobalEvents_Impl::getElementType() sal_Bool SAL_CALL SfxGlobalEvents_Impl::hasElements() { // SAFE -> - ::osl::ResettableMutexGuard aLock(m_aLock); + osl::MutexGuard aLock(m_aLock); return (!m_lModels.empty()); // <- SAFE } @@ -360,7 +359,7 @@ void SfxGlobalEvents_Impl::implts_checkAndExecuteEventBindings(const document::D try { // SAFE -> - ::osl::ResettableMutexGuard aLock(m_aLock); + osl::ClearableMutexGuard aLock(m_aLock); uno::Reference< container::XNameReplace > xEvents = m_xEvents; aLock.clear(); // <- SAFE diff --git a/svl/source/config/itemholder2.cxx b/svl/source/config/itemholder2.cxx index 61b1071462f5..b19ce9b644ca 100644 --- a/svl/source/config/itemholder2.cxx +++ b/svl/source/config/itemholder2.cxx @@ -79,7 +79,7 @@ void SAL_CALL ItemHolder2::disposing(const css::lang::EventObject&) void ItemHolder2::impl_addItem(EItem eItem) { - ::osl::ResettableMutexGuard aLock(m_aLock); + osl::MutexGuard aLock(m_aLock); for ( auto const & rInfo : m_lItems ) { diff --git a/svtools/source/config/itemholder2.cxx b/svtools/source/config/itemholder2.cxx index c6b1034618ba..cbd78826d7c0 100644 --- a/svtools/source/config/itemholder2.cxx +++ b/svtools/source/config/itemholder2.cxx @@ -90,7 +90,7 @@ void SAL_CALL ItemHolder2::disposing(const css::lang::EventObject&) void ItemHolder2::impl_addItem(EItem eItem) { - ::osl::ResettableMutexGuard aLock(m_aLock); + osl::MutexGuard aLock(m_aLock); for ( auto const & rInfo : m_lItems ) { @@ -110,7 +110,7 @@ void ItemHolder2::impl_releaseAllItems() { std::vector<TItemInfo> items; { - ::osl::ResettableMutexGuard aLock(m_aLock); + osl::MutexGuard aLock(m_aLock); items.swap(m_lItems); } diff --git a/svtools/source/misc/acceleratorexecute.cxx b/svtools/source/misc/acceleratorexecute.cxx index 8ecfd2d64680..65632e04cb07 100644 --- a/svtools/source/misc/acceleratorexecute.cxx +++ b/svtools/source/misc/acceleratorexecute.cxx @@ -182,7 +182,7 @@ bool AcceleratorExecute::execute(const css::awt::KeyEvent& aAWTKey) } // SAFE -> ---------------------------------- - ::osl::ResettableMutexGuard aLock(m_aLock); + osl::ClearableMutexGuard aLock(m_aLock); css::uno::Reference< css::frame::XDispatchProvider > xProvider = m_xDispatcher; @@ -247,7 +247,7 @@ OUString AcceleratorExecute::findCommand(const css::awt::KeyEvent& aKey) OUString AcceleratorExecute::impl_ts_findCommand(const css::awt::KeyEvent& aKey) { // SAFE -> ---------------------------------- - ::osl::ResettableMutexGuard aLock(m_aLock); + osl::ClearableMutexGuard aLock(m_aLock); css::uno::Reference< css::ui::XAcceleratorConfiguration > xGlobalCfg = m_xGlobalCfg; css::uno::Reference< css::ui::XAcceleratorConfiguration > xModuleCfg = m_xModuleCfg; diff --git a/svtools/source/uno/popupmenucontrollerbase.cxx b/svtools/source/uno/popupmenucontrollerbase.cxx index 8bf253442d55..9ce87c67c0af 100644 --- a/svtools/source/uno/popupmenucontrollerbase.cxx +++ b/svtools/source/uno/popupmenucontrollerbase.cxx @@ -167,9 +167,10 @@ void SAL_CALL PopupMenuControllerBase::itemDeactivated( const awt::MenuEvent& ) void SAL_CALL PopupMenuControllerBase::updatePopupMenu() { - osl::ClearableMutexGuard aLock( m_aMutex ); - throwIfDisposed(); - aLock.clear(); + { + osl::MutexGuard aLock(m_aMutex); + throwIfDisposed(); + } updateCommand( m_aCommandURL ); } @@ -211,9 +212,10 @@ Sequence< Reference< XDispatch > > SAL_CALL PopupMenuControllerBase::queryDispat { // Create return list - which must have same size then the given descriptor // It's not allowed to pack it! - osl::ClearableMutexGuard aLock( m_aMutex ); - throwIfDisposed(); - aLock.clear(); + { + osl::MutexGuard aLock(m_aMutex); + throwIfDisposed(); + } sal_Int32 nCount = lDescriptor.getLength(); uno::Sequence< uno::Reference< frame::XDispatch > > lDispatcher( nCount ); diff --git a/svx/source/accessibility/AccessibleTextHelper.cxx b/svx/source/accessibility/AccessibleTextHelper.cxx index 66db23d76fa4..0f8b8412a06e 100644 --- a/svx/source/accessibility/AccessibleTextHelper.cxx +++ b/svx/source/accessibility/AccessibleTextHelper.cxx @@ -1392,22 +1392,24 @@ namespace accessibility void AccessibleTextHelper_Impl::FireEvent( const sal_Int16 nEventId, const uno::Any& rNewValue, const uno::Any& rOldValue ) const { // -- object locked -- - ::osl::ClearableMutexGuard aGuard( maMutex ); - AccessibleEventObject aEvent; + { + osl::MutexGuard aGuard(maMutex); - DBG_ASSERT(mxFrontEnd.is(), "AccessibleTextHelper::FireEvent: no event source set" ); + DBG_ASSERT(mxFrontEnd.is(), "AccessibleTextHelper::FireEvent: no event source set"); - if( mxFrontEnd.is() ) - aEvent = AccessibleEventObject(mxFrontEnd->getAccessibleContext(), nEventId, rNewValue, rOldValue); - else - aEvent = AccessibleEventObject(uno::Reference< uno::XInterface >(), nEventId, rNewValue, rOldValue); + if (mxFrontEnd.is()) + aEvent = AccessibleEventObject(mxFrontEnd->getAccessibleContext(), nEventId, + rNewValue, rOldValue); + else + aEvent = AccessibleEventObject(uno::Reference<uno::XInterface>(), nEventId, + rNewValue, rOldValue); - // no locking necessary, FireEvent internally copies listeners - // if someone removes/adds in between Further locking, - // actually, might lead to deadlocks, since we're calling out - // of this object - aGuard.clear(); + // no locking necessary, FireEvent internally copies listeners + // if someone removes/adds in between Further locking, + // actually, might lead to deadlocks, since we're calling out + // of this object + } // -- until here -- FireEvent(aEvent); diff --git a/toolkit/source/controls/unocontrols.cxx b/toolkit/source/controls/unocontrols.cxx index 50b954452a30..937b05745273 100644 --- a/toolkit/source/controls/unocontrols.cxx +++ b/toolkit/source/controls/unocontrols.cxx @@ -2344,7 +2344,7 @@ void SAL_CALL UnoControlListBoxModel::setItemTextAndImage( ::sal_Int32 i_nPositi void SAL_CALL UnoControlListBoxModel::setItemData( ::sal_Int32 i_nPosition, const Any& i_rDataValue ) { - ::osl::ClearableMutexGuard aGuard( GetMutex() ); + osl::MutexGuard aGuard( GetMutex() ); ListItem& rItem( m_xData->getItem( i_nPosition ) ); rItem.ItemData = i_rDataValue; } @@ -2376,7 +2376,7 @@ beans::Pair< OUString, OUString > SAL_CALL UnoControlListBoxModel::getItemTextAn Any SAL_CALL UnoControlListBoxModel::getItemData( ::sal_Int32 i_nPosition ) { - ::osl::ClearableMutexGuard aGuard( GetMutex() ); + osl::MutexGuard aGuard( GetMutex() ); const ListItem& rItem( m_xData->getItem( i_nPosition ) ); return rItem.ItemData; } diff --git a/ucb/source/ucp/webdav-neon/NeonLockStore.cxx b/ucb/source/ucp/webdav-neon/NeonLockStore.cxx index 4543778fa81a..13b24f7b665d 100644 --- a/ucb/source/ucp/webdav-neon/NeonLockStore.cxx +++ b/ucb/source/ucp/webdav-neon/NeonLockStore.cxx @@ -106,9 +106,10 @@ NeonLockStore::NeonLockStore() NeonLockStore::~NeonLockStore() { - osl::ResettableMutexGuard aGuard(m_aMutex); - stopTicker(aGuard); - aGuard.reset(); // actually no threads should even try to access members now + { + osl::ClearableMutexGuard aGuard(m_aMutex); + stopTicker(aGuard); + } // actually no threads should even try to access members now // release active locks, if any. SAL_WARN_IF( !m_aLockInfoMap.empty(), "ucb.ucp.webdav", "NeonLockStore::~NeonLockStore - Releasing active locks!" ); diff --git a/unotools/source/config/itemholder1.cxx b/unotools/source/config/itemholder1.cxx index bf74770f34a2..3af5dbf1b302 100644 --- a/unotools/source/config/itemholder1.cxx +++ b/unotools/source/config/itemholder1.cxx @@ -95,7 +95,7 @@ void SAL_CALL ItemHolder1::disposing(const css::lang::EventObject&) void ItemHolder1::impl_addItem(EItem eItem) { - ::osl::ResettableMutexGuard aLock(m_aLock); + osl::MutexGuard aLock(m_aLock); for ( auto const & rInfo : m_lItems ) { diff --git a/vcl/source/components/dtranscomp.cxx b/vcl/source/components/dtranscomp.cxx index dd1bf719ffa6..b443ca86595a 100644 --- a/vcl/source/components/dtranscomp.cxx +++ b/vcl/source/components/dtranscomp.cxx @@ -169,14 +169,14 @@ sal_Int8 GenericClipboard::getRenderingCapabilities() void GenericClipboard::addClipboardListener( const Reference< datatransfer::clipboard::XClipboardListener >& listener ) { - osl::ClearableMutexGuard aGuard( m_aMutex ); + osl::MutexGuard aGuard(m_aMutex); m_aListeners.push_back( listener ); } void GenericClipboard::removeClipboardListener( const Reference< datatransfer::clipboard::XClipboardListener >& listener ) { - osl::ClearableMutexGuard aGuard( m_aMutex ); + osl::MutexGuard aGuard(m_aMutex); m_aListeners.erase(std::remove(m_aListeners.begin(), m_aListeners.end(), listener), m_aListeners.end()); } |