From 4bd2ed6a919c1c970dda6e9f58b813d6b59a6eb5 Mon Sep 17 00:00:00 2001 From: Norbert Thiebaud Date: Thu, 14 Oct 2010 22:09:00 -0500 Subject: convert OClearableGuard(SolarMutex) to SolarMutex(Clearable)Guard. Most OClearableGuard of the Solar Mutex could be converted to a simple SolarMutexGuard. a couple of site were converted to a SolarMutexClearableGuard, were converting to a SolarMutexGuard would have made the code more convoluted. --- .../source/dispatch/windowcommanddispatch.cxx | 14 ++--- framework/source/helper/persistentwindowstate.cxx | 8 +-- framework/source/helper/statusindicatorfactory.cxx | 2 +- framework/source/helper/tagwindowasmodified.cxx | 4 +- framework/source/helper/titlebarupdate.cxx | 8 +-- framework/source/helper/vclstatusindicator.cxx | 66 +++++++++++----------- framework/source/loadenv/loadenv.cxx | 12 ++-- framework/source/services/frame.cxx | 21 +++---- framework/source/services/taskcreatorsrv.cxx | 3 +- 9 files changed, 64 insertions(+), 74 deletions(-) (limited to 'framework') diff --git a/framework/source/dispatch/windowcommanddispatch.cxx b/framework/source/dispatch/windowcommanddispatch.cxx index dd88cf890622..7138f2656cc8 100644 --- a/framework/source/dispatch/windowcommanddispatch.cxx +++ b/framework/source/dispatch/windowcommanddispatch.cxx @@ -106,15 +106,15 @@ void WindowCommandDispatch::impl_startListening() return; // SYNCHRONIZED -> - ::vos::OClearableGuard aSolarLock(Application::GetSolarMutex()); - - Window* pWindow = VCLUnoHelper::GetWindow(xWindow); - if ( ! pWindow) - return; + { + SolarMutexGuard aSolarLock; - pWindow->AddEventListener( LINK(this, WindowCommandDispatch, impl_notifyCommand) ); + Window* pWindow = VCLUnoHelper::GetWindow(xWindow); + if ( ! pWindow) + return; - aSolarLock.clear(); + pWindow->AddEventListener( LINK(this, WindowCommandDispatch, impl_notifyCommand) ); + } // <- SYNCHRONIZED } diff --git a/framework/source/helper/persistentwindowstate.cxx b/framework/source/helper/persistentwindowstate.cxx index d0d21d384936..de582de5a145 100644 --- a/framework/source/helper/persistentwindowstate.cxx +++ b/framework/source/helper/persistentwindowstate.cxx @@ -285,7 +285,7 @@ void PersistentWindowState::implst_setWindowStateOnConfig(const css::uno::Refere if (xWindow.is()) { // SOLAR SAFE -> ------------------------ - ::vos::OClearableGuard aSolarLock(Application::GetSolarMutex()); + SolarMutexGuard aSolarGuard; Window* pWindow = VCLUnoHelper::GetWindow(xWindow); // check for system window is neccessary to guarantee correct pointer cast! @@ -300,8 +300,6 @@ void PersistentWindowState::implst_setWindowStateOnConfig(const css::uno::Refere ((SystemWindow*)pWindow)->GetWindowState(nMask), RTL_TEXTENCODING_UTF8); } - - aSolarLock.clear(); // <- SOLAR SAFE ------------------------ } @@ -320,7 +318,7 @@ void PersistentWindowState::implst_setWindowStateOnWindow(const css::uno::Refere return; // SOLAR SAFE -> ------------------------ - ::vos::OClearableGuard aSolarLock(Application::GetSolarMutex()); + SolarMutexGuard aSolarGuard; Window* pWindow = VCLUnoHelper::GetWindow(xWindow); if (!pWindow) @@ -341,8 +339,6 @@ void PersistentWindowState::implst_setWindowStateOnWindow(const css::uno::Refere return; pSystemWindow->SetWindowState(U2B_ENC(sWindowState,RTL_TEXTENCODING_UTF8)); - - aSolarLock.clear(); // <- SOLAR SAFE ------------------------ } diff --git a/framework/source/helper/statusindicatorfactory.cxx b/framework/source/helper/statusindicatorfactory.cxx index 465e55c48285..c063fd34241b 100644 --- a/framework/source/helper/statusindicatorfactory.cxx +++ b/framework/source/helper/statusindicatorfactory.cxx @@ -428,7 +428,7 @@ void StatusIndicatorFactory::implts_makeParentVisibleIfAllowed() // is visible too. impl_showProgress(); - ::vos::OClearableGuard aSolarGuard(Application::GetSolarMutex()); + SolarMutexGuard aSolarGuard; Window* pWindow = VCLUnoHelper::GetWindow(xParentWindow); if ( pWindow ) { diff --git a/framework/source/helper/tagwindowasmodified.cxx b/framework/source/helper/tagwindowasmodified.cxx index 3abda2a1400e..1ce45a0046ad 100644 --- a/framework/source/helper/tagwindowasmodified.cxx +++ b/framework/source/helper/tagwindowasmodified.cxx @@ -141,7 +141,7 @@ void SAL_CALL TagWindowAsModified::modified(const css::lang::EventObject& aEvent ::sal_Bool bModified = xModel->isModified (); // SYNCHRONIZED -> - ::vos::OClearableGuard aSolarGuard(Application::GetSolarMutex()); + SolarMutexGuard aSolarGuard; Window* pWindow = VCLUnoHelper::GetWindow(xWindow); if ( ! pWindow) @@ -156,8 +156,6 @@ void SAL_CALL TagWindowAsModified::modified(const css::lang::EventObject& aEvent pWindow->SetExtendedStyle(WB_EXT_DOCMODIFIED); else pWindow->SetExtendedStyle( ! WB_EXT_DOCMODIFIED); - - aSolarGuard.clear(); // <- SYNCHRONIZED } diff --git a/framework/source/helper/titlebarupdate.cxx b/framework/source/helper/titlebarupdate.cxx index fd2154f6f359..58b7d987d0fb 100644 --- a/framework/source/helper/titlebarupdate.cxx +++ b/framework/source/helper/titlebarupdate.cxx @@ -310,7 +310,7 @@ void TitleBarUpdate::impl_updateIcon(const css::uno::Reference< css::frame::XFra // Check window pointer for right WorkWindow class too!!! // VCL SYNCHRONIZED -> - ::vos::OClearableGuard aSolarLock( Application::GetSolarMutex() ); + SolarMutexGuard aSolarGuard; Window* pWindow = (VCLUnoHelper::GetWindow( xWindow )); if ( @@ -327,8 +327,6 @@ void TitleBarUpdate::impl_updateIcon(const css::uno::Reference< css::frame::XFra aURL = xModel->getURL(); pWorkWindow->SetRepresentedURL( aURL ); } - - aSolarLock.clear(); // <- VCL SYNCHRONIZED } @@ -347,7 +345,7 @@ void TitleBarUpdate::impl_updateTitle(const css::uno::Reference< css::frame::XFr const ::rtl::OUString sTitle = xTitle->getTitle (); // VCL SYNCHRONIZED -> - ::vos::OClearableGuard aSolarLock( Application::GetSolarMutex() ); + SolarMutexGuard aSolarGuard; Window* pWindow = (VCLUnoHelper::GetWindow( xWindow )); if ( @@ -358,8 +356,6 @@ void TitleBarUpdate::impl_updateTitle(const css::uno::Reference< css::frame::XFr WorkWindow* pWorkWindow = (WorkWindow*)pWindow; pWorkWindow->SetText( sTitle ); } - - aSolarLock.clear(); // <- VCL SYNCHRONIZED } diff --git a/framework/source/helper/vclstatusindicator.cxx b/framework/source/helper/vclstatusindicator.cxx index d9861169d5cc..1578b3d45454 100644 --- a/framework/source/helper/vclstatusindicator.cxx +++ b/framework/source/helper/vclstatusindicator.cxx @@ -91,24 +91,24 @@ void SAL_CALL VCLStatusIndicator::start(const ::rtl::OUString& sText , // <- SAFE ---------------------------------- // SOLAR SAFE -> ---------------------------- - ::vos::OClearableGuard aSolarLock(Application::GetSolarMutex()); - - Window* pParentWindow = VCLUnoHelper::GetWindow(xParentWindow); - if (!m_pStatusBar) - m_pStatusBar = new StatusBar(pParentWindow, WB_3DLOOK|WB_BORDER); + { + SolarMutexGuard aSolarGuard; - VCLStatusIndicator::impl_recalcLayout(m_pStatusBar, pParentWindow); + Window* pParentWindow = VCLUnoHelper::GetWindow(xParentWindow); + if (!m_pStatusBar) + m_pStatusBar = new StatusBar(pParentWindow, WB_3DLOOK|WB_BORDER); - m_pStatusBar->Show(); - m_pStatusBar->StartProgressMode(sText); - m_pStatusBar->SetProgressValue(0); + VCLStatusIndicator::impl_recalcLayout(m_pStatusBar, pParentWindow); - // force repaint! - pParentWindow->Show(); - pParentWindow->Invalidate(INVALIDATE_CHILDREN); - pParentWindow->Flush(); + m_pStatusBar->Show(); + m_pStatusBar->StartProgressMode(sText); + m_pStatusBar->SetProgressValue(0); - aSolarLock.clear(); + // force repaint! + pParentWindow->Show(); + pParentWindow->Invalidate(INVALIDATE_CHILDREN); + pParentWindow->Flush(); + } // <- SOLAR SAFE ---------------------------- // SAFE -> ---------------------------------- @@ -125,13 +125,12 @@ void SAL_CALL VCLStatusIndicator::reset() throw(css::uno::RuntimeException) { // SOLAR SAFE -> ---------------------------- - ::vos::OClearableGuard aSolarLock(Application::GetSolarMutex()); + SolarMutexGuard aSolarGuard; if (m_pStatusBar) { m_pStatusBar->SetProgressValue(0); m_pStatusBar->SetText(String()); } - aSolarLock.clear(); // <- SOLAR SAFE ---------------------------- } @@ -148,16 +147,17 @@ void SAL_CALL VCLStatusIndicator::end() // <- SAFE ---------------------------------- // SOLAR SAFE -> ---------------------------- - ::vos::OClearableGuard aSolarLock(Application::GetSolarMutex()); - if (m_pStatusBar) { - m_pStatusBar->EndProgressMode(); - m_pStatusBar->Show(sal_False); - - delete m_pStatusBar; - m_pStatusBar = 0; + SolarMutexGuard aSolarGuard; + if (m_pStatusBar) + { + m_pStatusBar->EndProgressMode(); + m_pStatusBar->Show(sal_False); + + delete m_pStatusBar; + m_pStatusBar = 0; + } } - aSolarLock.clear(); // <- SOLAR SAFE ---------------------------- } @@ -172,10 +172,11 @@ void SAL_CALL VCLStatusIndicator::setText(const ::rtl::OUString& sText) // <- SAFE ---------------------------------- // SOLAR SAFE -> ---------------------------- - ::vos::OClearableGuard aSolarLock(Application::GetSolarMutex()); - if (m_pStatusBar) - m_pStatusBar->SetText(sText); - aSolarLock.clear(); + { + SolarMutexGuard aSolarGuard; + if (m_pStatusBar) + m_pStatusBar->SetText(sText); + } // <- SOLAR SAFE ---------------------------- } @@ -203,10 +204,11 @@ void SAL_CALL VCLStatusIndicator::setValue(sal_Int32 nValue) ((nValue*100) / ::std::max(nRange,(sal_Int32)1)), (sal_Int32)100)); // SOLAR SAFE -> ---------------------------- - ::vos::OClearableGuard aSolarLock(Application::GetSolarMutex()); - if (m_pStatusBar) - m_pStatusBar->SetProgressValue(nPercent); - aSolarLock.clear(); + { + SolarMutexGuard aSolarGuard; + if (m_pStatusBar) + m_pStatusBar->SetProgressValue(nPercent); + } // <- SOLAR SAFE ---------------------------- } diff --git a/framework/source/loadenv/loadenv.cxx b/framework/source/loadenv/loadenv.cxx index 26972b1cb3db..39314fe9d9af 100644 --- a/framework/source/loadenv/loadenv.cxx +++ b/framework/source/loadenv/loadenv.cxx @@ -1639,7 +1639,7 @@ void LoadEnv::impl_reactForLoadingState() if (bMinimized) { - ::vos::OClearableGuard aSolarGuard(Application::GetSolarMutex()); + SolarMutexGuard aSolarGuard; Window* pWindow = VCLUnoHelper::GetWindow(xWindow); // check for system window is neccessary to guarantee correct pointer cast! if (pWindow && pWindow->IsSystemWindow()) @@ -1750,7 +1750,7 @@ void LoadEnv::impl_makeFrameWindowVisible(const css::uno::Reference< css::awt::X aReadLock.unlock(); // <- SAFE ---------------------------------- - ::vos::OClearableGuard aSolarGuard(Application::GetSolarMutex()); + SolarMutexGuard aSolarGuard; Window* pWindow = VCLUnoHelper::GetWindow(xWindow); if ( pWindow ) { @@ -1818,7 +1818,7 @@ void LoadEnv::impl_applyPersistentWindowState(const css::uno::Reference< css::aw return; // SOLAR SAFE -> - ::vos::OClearableGuard aSolarLock1(Application::GetSolarMutex()); + SolarMutexClearableGuard aSolarGuard1; Window* pWindow = VCLUnoHelper::GetWindow(xWindow); if (!pWindow) @@ -1835,7 +1835,7 @@ void LoadEnv::impl_applyPersistentWindowState(const css::uno::Reference< css::aw if (pWorkWindow->IsMinimized()) return; - aSolarLock1.clear(); + aSolarGuard1.clear(); // <- SOLAR SAFE // SAFE -> @@ -1877,7 +1877,7 @@ void LoadEnv::impl_applyPersistentWindowState(const css::uno::Reference< css::aw if (sWindowState.getLength()) { // SOLAR SAFE -> - ::vos::OClearableGuard aSolarLock2(Application::GetSolarMutex()); + SolarMutexGuard aSolarGuard; // We have to retrieve the window pointer again. Because nobody can guarantee // that the XWindow was not disposed inbetween .-) @@ -1890,8 +1890,6 @@ void LoadEnv::impl_applyPersistentWindowState(const css::uno::Reference< css::aw SystemWindow* pSystemWindow = (SystemWindow*)pWindowCheck; pSystemWindow->SetWindowState(U2B_ENC(sWindowState,RTL_TEXTENCODING_UTF8)); - - aSolarLock2.clear(); // <- SOLAR SAFE } } diff --git a/framework/source/services/frame.cxx b/framework/source/services/frame.cxx index f0f1aaf6e661..7113181372bd 100644 --- a/framework/source/services/frame.cxx +++ b/framework/source/services/frame.cxx @@ -2304,7 +2304,7 @@ aEvent // Deactivation is always done implicitely by activation of another frame. // Only if no activation is done, deactivations have to be processed if the activated window // is a parent window of the last active Window! - ::vos::OClearableGuard aSolarGuard( Application::GetSolarMutex() ); + SolarMutexClearableGuard aSolarGuard; // CheckMenuCloser_Impl(); Window* pFocusWindow = Application::GetFocusWindow(); if ( @@ -2910,17 +2910,18 @@ void Frame::implts_setIconOnWindow() // Don't forget SolarMutex! We use vcl directly :-( // Check window pointer for right WorkWindow class too!!! /* SAFE AREA ----------------------------------------------------------------------------------------------- */ - ::vos::OClearableGuard aSolarGuard( Application::GetSolarMutex() ); - Window* pWindow = (VCLUnoHelper::GetWindow( xContainerWindow )); - if( - ( pWindow != NULL ) && - ( pWindow->GetType() == WINDOW_WORKWINDOW ) - ) { - WorkWindow* pWorkWindow = (WorkWindow*)pWindow; - pWorkWindow->SetIcon( (sal_uInt16)nIcon ); + SolarMutexGuard aSolarGuard; + Window* pWindow = (VCLUnoHelper::GetWindow( xContainerWindow )); + if( + ( pWindow != NULL ) && + ( pWindow->GetType() == WINDOW_WORKWINDOW ) + ) + { + WorkWindow* pWorkWindow = (WorkWindow*)pWindow; + pWorkWindow->SetIcon( (sal_uInt16)nIcon ); + } } - aSolarGuard.clear(); /* UNSAFE AREA --------------------------------------------------------------------------------------------- */ } } diff --git a/framework/source/services/taskcreatorsrv.cxx b/framework/source/services/taskcreatorsrv.cxx index 02b030867be7..ac34efd1baa1 100644 --- a/framework/source/services/taskcreatorsrv.cxx +++ b/framework/source/services/taskcreatorsrv.cxx @@ -227,11 +227,10 @@ css::uno::Reference< css::uno::XInterface > SAL_CALL TaskCreatorService::createI void TaskCreatorService::implts_applyDocStyleToWindow(const css::uno::Reference< css::awt::XWindow >& xWindow) const { // SYNCHRONIZED -> - ::vos::OClearableGuard aSolarGuard(Application::GetSolarMutex()); + SolarMutexGuard aSolarGuard; Window* pVCLWindow = VCLUnoHelper::GetWindow(xWindow); if (pVCLWindow) pVCLWindow->SetExtendedStyle(WB_EXT_DOCUMENT); - aSolarGuard.clear(); // <- SYNCHRONIZED } -- cgit