summaryrefslogtreecommitdiff
path: root/desktop
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2011-05-17 11:59:19 +0100
committerCaolán McNamara <caolanm@redhat.com>2011-05-20 15:23:08 +0100
commitf8853c9f4eaa8faa0c6c452a5324dca0621571ef (patch)
tree889aa5f7622ead73d7d85e82c3ed76b10bde69d1 /desktop
parent3eaec7a874b2c4ad2a5249a078176475e8fe80fa (diff)
valgrind: use non-leaky singleton pattern here
Diffstat (limited to 'desktop')
-rw-r--r--desktop/source/app/dispatchwatcher.cxx15
-rw-r--r--desktop/source/app/dispatchwatcher.hxx2
2 files changed, 6 insertions, 11 deletions
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 <vector>
#include <osl/thread.hxx>
+#include <rtl/instance.hxx>
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, theWatcherMutex> {};
+}
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;
};