summaryrefslogtreecommitdiff
path: root/desktop
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2011-05-17 11:37:57 +0100
committerCaolán McNamara <caolanm@redhat.com>2011-05-20 15:23:08 +0100
commit3eaec7a874b2c4ad2a5249a078176475e8fe80fa (patch)
treec37e1684b956df8050b893b1f6929eaa834d0826 /desktop
parentc3f4ddfcc633f893316b12ab199fd52914ad7f50 (diff)
valgrind: use non-leaky singleton pattern here
Diffstat (limited to 'desktop')
-rw-r--r--desktop/source/app/officeipcthread.cxx22
-rw-r--r--desktop/source/app/officeipcthread.hxx1
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 <rtl/strbuf.hxx>
#include <comphelper/processfactory.hxx>
#include <osl/file.hxx>
-#include "rtl/process.h"
+#include <rtl/process.h>
+#include <rtl/instance.hxx>
#include "tools/getprocessworkingdir.hxx"
using namespace desktop;
@@ -223,7 +224,6 @@ bool addArgument(
OfficeIPCThread* OfficeIPCThread::pGlobalOfficeIPCThread = 0;
namespace { struct Security : public rtl::Static<osl::Security, Security> {}; }
-::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<osl::Mutex, theOfficeIPCThreadMutex> {};
+}
- 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;