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 /framework/source | |
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>
Diffstat (limited to 'framework/source')
20 files changed, 533 insertions, 518 deletions
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() ) { |