From b250344e88434741d4fae99a7ef198c46e020132 Mon Sep 17 00:00:00 2001 From: Luboš Luňák Date: Tue, 5 Oct 2010 15:49:42 +0200 Subject: refactor several SolarMutex releaser classes into one --- svtools/source/contnr/fileview.cxx | 21 +-------------------- toolkit/source/awt/vclxwindow.cxx | 2 +- vcl/inc/vcl/svapp.hxx | 20 ++++++++++++++++++++ vcl/source/helper/xconnection.cxx | 19 ------------------- 4 files changed, 22 insertions(+), 40 deletions(-) diff --git a/svtools/source/contnr/fileview.cxx b/svtools/source/contnr/fileview.cxx index af19379d8b8f..f6c4dc01434e 100644 --- a/svtools/source/contnr/fileview.cxx +++ b/svtools/source/contnr/fileview.cxx @@ -108,25 +108,6 @@ DECLARE_LIST( StringList_Impl, OUString* ) namespace { - //==================================================================== - //= ReleaseSolarMutex - //==================================================================== - struct ReleaseSolarMutex - { - private: - ULONG m_nCount; - - public: - inline ReleaseSolarMutex() - { - m_nCount = Application::ReleaseSolarMutex(); - } - inline ~ReleaseSolarMutex() - { - Application::AcquireSolarMutex( m_nCount ); - } - }; - //==================================================================== //= ITimeoutHandler //==================================================================== @@ -2022,7 +2003,7 @@ FileViewResult SvtFileView_Impl::GetFolderContent_Impl( // also release the SolarMutex. Not all code which is needed during the enumeration // is Solar-Thread-Safe, in particular there is some code which needs to access // string resources (and our resource system relies on the SolarMutex :() - ReleaseSolarMutex aSolarRelease; + SolarMutexReleaser aSolarRelease; // now wait. Note that if we didn't get an pAsyncDescriptor, then this is an infinite wait. eResult = m_aAsyncActionFinished.wait( pTimeout.get() ); diff --git a/toolkit/source/awt/vclxwindow.cxx b/toolkit/source/awt/vclxwindow.cxx index efc2c40c6baa..3e798c3f0ecd 100644 --- a/toolkit/source/awt/vclxwindow.cxx +++ b/toolkit/source/awt/vclxwindow.cxx @@ -339,7 +339,7 @@ IMPL_LINK( VCLXWindowImpl, OnProcessCallbacks, void*, EMPTYARG ) } { - ::toolkit::ReleaseSolarMutex aReleaseSolar; + SolarMutexReleaser aReleaseSolar; for ( CallbackArray::const_iterator loop = aCallbacksCopy.begin(); loop != aCallbacksCopy.end(); ++loop diff --git a/vcl/inc/vcl/svapp.hxx b/vcl/inc/vcl/svapp.hxx index f90326ce50eb..8dbbe5221434 100644 --- a/vcl/inc/vcl/svapp.hxx +++ b/vcl/inc/vcl/svapp.hxx @@ -498,6 +498,26 @@ private: DECL_STATIC_LINK( Application, PostEventHandler, void* ); }; +/** + A helper class that calls Application::ReleaseSolarMutex() in its constructor + and restores the mutex in its destructor. +*/ +class SolarMutexReleaser +{ + ULONG mnReleased; +public: + SolarMutexReleaser() + { + mnReleased = Application::ReleaseSolarMutex(); + } + + ~SolarMutexReleaser() + { + if( mnReleased ) + Application::AcquireSolarMutex( mnReleased ); + } +}; + VCL_DLLPUBLIC Application* GetpApp(); VCL_DLLPUBLIC BOOL InitVCL( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & ); diff --git a/vcl/source/helper/xconnection.cxx b/vcl/source/helper/xconnection.cxx index caf7ee237d67..c15e368d3791 100644 --- a/vcl/source/helper/xconnection.cxx +++ b/vcl/source/helper/xconnection.cxx @@ -34,25 +34,6 @@ #include "vcl/salinst.hxx" #include "vcl/svapp.hxx" -namespace vcl -{ - class SolarMutexReleaser - { - ULONG mnReleased; - public: - SolarMutexReleaser() - { - mnReleased = Application::ReleaseSolarMutex(); - } - - ~SolarMutexReleaser() - { - if( mnReleased ) - Application::AcquireSolarMutex( mnReleased ); - } - }; -} - using namespace rtl; using namespace osl; using namespace vcl; -- cgit v1.2.3