From f8853c9f4eaa8faa0c6c452a5324dca0621571ef Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Tue, 17 May 2011 11:59:19 +0100 Subject: valgrind: use non-leaky singleton pattern here --- desktop/source/app/dispatchwatcher.cxx | 15 ++++++--------- desktop/source/app/dispatchwatcher.hxx | 2 -- 2 files changed, 6 insertions(+), 11 deletions(-) (limited to 'desktop') diff --git a/desktop/source/app/dispatchwatcher.cxx b/desktop/source/app/dispatchwatcher.cxx index a04a1605db1f..28182d7e0db6 100644 --- a/desktop/source/app/dispatchwatcher.cxx +++ b/desktop/source/app/dispatchwatcher.cxx @@ -63,6 +63,7 @@ #include #include +#include using ::rtl::OUString; using namespace ::osl; @@ -122,18 +123,14 @@ static OUString impl_GuessFilter( OUString aUrlIn, OUString aUrlOut ) return impl_GetFilterFromExt( aUrlOut, SFX_FILTER_EXPORT, aAppl ); } -Mutex* DispatchWatcher::pWatcherMutex = NULL; +namespace +{ + class theWatcherMutex : public rtl::Static {}; +} Mutex& DispatchWatcher::GetMutex() { - if ( !pWatcherMutex ) - { - ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); - if ( !pWatcherMutex ) - pWatcherMutex = new osl::Mutex(); - } - - return *pWatcherMutex; + return theWatcherMutex::get(); } // Create or get the dispatch watcher implementation. This implementation must be diff --git a/desktop/source/app/dispatchwatcher.hxx b/desktop/source/app/dispatchwatcher.hxx index 0fde60da603f..7146a29b3fd2 100644 --- a/desktop/source/app/dispatchwatcher.hxx +++ b/desktop/source/app/dispatchwatcher.hxx @@ -118,8 +118,6 @@ class DispatchWatcher : public ::cppu::WeakImplHelper1< ::com::sun::star::frame: DispatchWatcherHashMap m_aRequestContainer; - static ::osl::Mutex* pWatcherMutex; - sal_Int16 m_nRequestCount; }; -- cgit