From 3eaec7a874b2c4ad2a5249a078176475e8fe80fa Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Tue, 17 May 2011 11:37:57 +0100 Subject: valgrind: use non-leaky singleton pattern here --- desktop/source/app/officeipcthread.cxx | 22 +++++++++------------- desktop/source/app/officeipcthread.hxx | 1 - 2 files changed, 9 insertions(+), 14 deletions(-) diff --git a/desktop/source/app/officeipcthread.cxx b/desktop/source/app/officeipcthread.cxx index 1c2c3a17c245..d7379ee7b887 100644 --- a/desktop/source/app/officeipcthread.cxx +++ b/desktop/source/app/officeipcthread.cxx @@ -50,7 +50,8 @@ #include #include #include -#include "rtl/process.h" +#include +#include #include "tools/getprocessworkingdir.hxx" using namespace desktop; @@ -223,7 +224,6 @@ bool addArgument( OfficeIPCThread* OfficeIPCThread::pGlobalOfficeIPCThread = 0; namespace { struct Security : public rtl::Static {}; } -::osl::Mutex* OfficeIPCThread::pOfficeIPCThreadMutex = 0; // Turns a string in aMsg such as file:///home/foo/.libreoffice/3 // Into a hex string of well known length ff132a86... @@ -360,19 +360,15 @@ throw( RuntimeException ) { } -// ---------------------------------------------------------------------------- - -::osl::Mutex& OfficeIPCThread::GetMutex() +namespace { - // Get or create our mutex for thread-saftey - if ( !pOfficeIPCThreadMutex ) - { - ::osl::MutexGuard aGuard( osl::Mutex::getGlobalMutex() ); - if ( !pOfficeIPCThreadMutex ) - pOfficeIPCThreadMutex = new osl::Mutex; - } + class theOfficeIPCThreadMutex + : public rtl::Static {}; +} - return *pOfficeIPCThreadMutex; +::osl::Mutex& OfficeIPCThread::GetMutex() +{ + return theOfficeIPCThreadMutex::get(); } void OfficeIPCThread::SetDowning() diff --git a/desktop/source/app/officeipcthread.hxx b/desktop/source/app/officeipcthread.hxx index e50e46c280ea..a1fe4c5f772a 100644 --- a/desktop/source/app/officeipcthread.hxx +++ b/desktop/source/app/officeipcthread.hxx @@ -74,7 +74,6 @@ class OfficeIPCThread : public osl::Thread { private: static OfficeIPCThread* pGlobalOfficeIPCThread; - static ::osl::Mutex* pOfficeIPCThreadMutex; osl::Pipe maPipe; osl::StreamPipe maStreamPipe; -- cgit