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
commitd6c5f4f3d5c3a92ce94c0d25649d67ffe7faad4e (patch)
tree451c586c0585a10756126b7d8e9ced6bdfc34c53 /desktop
parentee60a220693cd94afd289d822f2b1af2236b2315 (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 9a1b6c3a4d..04816ffb92 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 a787c1e069..a756622542 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;
};