From 10dbb3b44f804c741bae6c4f467dd79d2d07d2be Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Tue, 18 Mar 2014 15:12:03 +0100 Subject: Use SolarMutexGuard directly Change-Id: Ia963e00be69d7a7b5b1d45f9827b05b69cd24a48 --- framework/inc/helper/vclstatusindicator.hxx | 4 +- framework/source/helper/vclstatusindicator.cxx | 100 +++++++------------------ 2 files changed, 29 insertions(+), 75 deletions(-) diff --git a/framework/inc/helper/vclstatusindicator.hxx b/framework/inc/helper/vclstatusindicator.hxx index 650c8e6a4fb6..ea3a38ba988b 100644 --- a/framework/inc/helper/vclstatusindicator.hxx +++ b/framework/inc/helper/vclstatusindicator.hxx @@ -20,7 +20,6 @@ #ifndef INCLUDED_FRAMEWORK_INC_HELPER_VCLSTATUSINDICATOR_HXX #define INCLUDED_FRAMEWORK_INC_HELPER_VCLSTATUSINDICATOR_HXX -#include #include #include #include @@ -38,8 +37,7 @@ namespace framework { // declaration -class VCLStatusIndicator : private ThreadHelpBase, // must be the first real base class! - public ::cppu::WeakImplHelper1< css::task::XStatusIndicator > +class VCLStatusIndicator : public ::cppu::WeakImplHelper1< css::task::XStatusIndicator > { // member diff --git a/framework/source/helper/vclstatusindicator.cxx b/framework/source/helper/vclstatusindicator.cxx index 099e02a8b57f..4bdb97a0d1b9 100644 --- a/framework/source/helper/vclstatusindicator.cxx +++ b/framework/source/helper/vclstatusindicator.cxx @@ -19,8 +19,6 @@ #include -#include - #include #include @@ -30,8 +28,7 @@ namespace framework { VCLStatusIndicator::VCLStatusIndicator(const css::uno::Reference< css::awt::XWindow >& xParentWindow) - : ThreadHelpBase (&Application::GetSolarMutex()) - , m_xParentWindow (xParentWindow ) + : m_xParentWindow (xParentWindow ) , m_pStatusBar (0 ) , m_nRange (0 ) , m_nValue (0 ) @@ -52,108 +49,75 @@ void SAL_CALL VCLStatusIndicator::start(const OUString& sText , sal_Int32 nRange) throw(css::uno::RuntimeException, std::exception) { - // SAFE -> ---------------------------------- - Guard aReadLock(m_aLock); - css::uno::Reference< css::awt::XWindow > xParentWindow = m_xParentWindow; - aReadLock.unlock(); - // <- SAFE ---------------------------------- - - // SOLAR SAFE -> ---------------------------- - { - SolarMutexGuard aSolarGuard; + SolarMutexGuard aSolarGuard; - Window* pParentWindow = VCLUnoHelper::GetWindow(xParentWindow); - if (!m_pStatusBar) - m_pStatusBar = new StatusBar(pParentWindow, WB_3DLOOK|WB_BORDER); + Window* pParentWindow = VCLUnoHelper::GetWindow(m_xParentWindow); + if (!m_pStatusBar) + m_pStatusBar = new StatusBar(pParentWindow, WB_3DLOOK|WB_BORDER); - VCLStatusIndicator::impl_recalcLayout(m_pStatusBar, pParentWindow); + VCLStatusIndicator::impl_recalcLayout(m_pStatusBar, pParentWindow); - m_pStatusBar->Show(); - m_pStatusBar->StartProgressMode(sText); - m_pStatusBar->SetProgressValue(0); + m_pStatusBar->Show(); + m_pStatusBar->StartProgressMode(sText); + m_pStatusBar->SetProgressValue(0); - // force repaint! - pParentWindow->Show(); - pParentWindow->Invalidate(INVALIDATE_CHILDREN); - pParentWindow->Flush(); - } - // <- SOLAR SAFE ---------------------------- + // force repaint! + pParentWindow->Show(); + pParentWindow->Invalidate(INVALIDATE_CHILDREN); + pParentWindow->Flush(); - // SAFE -> ---------------------------------- - Guard aWriteLock(m_aLock); m_sText = sText; m_nRange = nRange; m_nValue = 0; - aWriteLock.unlock(); - // <- SAFE ---------------------------------- } void SAL_CALL VCLStatusIndicator::reset() throw(css::uno::RuntimeException, std::exception) { - // SOLAR SAFE -> ---------------------------- SolarMutexGuard aSolarGuard; if (m_pStatusBar) { m_pStatusBar->SetProgressValue(0); m_pStatusBar->SetText(OUString()); } - // <- SOLAR SAFE ---------------------------- } void SAL_CALL VCLStatusIndicator::end() throw(css::uno::RuntimeException, std::exception) { - // SAFE -> ---------------------------------- - Guard aWriteLock(m_aLock); + SolarMutexGuard aSolarGuard; + m_sText = OUString(); m_nRange = 0; m_nValue = 0; - aWriteLock.unlock(); - // <- SAFE ---------------------------------- - // SOLAR SAFE -> ---------------------------- + if (m_pStatusBar) { - SolarMutexGuard aSolarGuard; - if (m_pStatusBar) - { - m_pStatusBar->EndProgressMode(); - m_pStatusBar->Show(false); - - delete m_pStatusBar; - m_pStatusBar = 0; - } + m_pStatusBar->EndProgressMode(); + m_pStatusBar->Show(false); + + delete m_pStatusBar; + m_pStatusBar = 0; } - // <- SOLAR SAFE ---------------------------- } void SAL_CALL VCLStatusIndicator::setText(const OUString& sText) throw(css::uno::RuntimeException, std::exception) { - // SAFE -> ---------------------------------- - Guard aWriteLock(m_aLock); + SolarMutexGuard aSolarGuard; m_sText = sText; - aWriteLock.unlock(); - // <- SAFE ---------------------------------- - - // SOLAR SAFE -> ---------------------------- - { - SolarMutexGuard aSolarGuard; - if (m_pStatusBar) - m_pStatusBar->SetText(sText); - } - // <- SOLAR SAFE ---------------------------- + if (m_pStatusBar) + m_pStatusBar->SetText(sText); } void SAL_CALL VCLStatusIndicator::setValue(sal_Int32 nValue) throw(css::uno::RuntimeException, std::exception) { - // SAFE -> ---------------------------------- - Guard aWriteLock(m_aLock); + SolarMutexGuard aSolarGuard; if (nValue <= m_nRange) m_nValue = nValue; @@ -161,23 +125,15 @@ void SAL_CALL VCLStatusIndicator::setValue(sal_Int32 nValue) m_nValue = m_nRange; sal_Int32 nRange = m_nRange; - nValue = m_nValue; - - aWriteLock.unlock(); - // <- SAFE ---------------------------------- + nValue = m_nValue; // normalize value to fit the range of 0-100 % sal_uInt16 nPercent = sal::static_int_cast< sal_uInt16 >( ::std::min( ((nValue*100) / ::std::max(nRange,(sal_Int32)1)), (sal_Int32)100)); - // SOLAR SAFE -> ---------------------------- - { - SolarMutexGuard aSolarGuard; - if (m_pStatusBar) - m_pStatusBar->SetProgressValue(nPercent); - } - // <- SOLAR SAFE ---------------------------- + if (m_pStatusBar) + m_pStatusBar->SetProgressValue(nPercent); } -- cgit v1.2.3