diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2011-09-09 14:41:53 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2011-09-09 17:46:37 +0200 |
commit | 1d38dbab29245e430792f7b3a4c14c94cd011504 (patch) | |
tree | 8a4d711e750675ec34e010be6e62a2313f1d6590 | |
parent | 21d97438e2944861e26e4984195f959a0cce1e41 (diff) |
sb140: #i117084# do not leak Lockfile instance
plus improvements based on a14010cb8c485ee1d07530d34a00f03db3233e02 "valgrind: fix leak"
-rw-r--r-- | desktop/inc/app.hxx | 3 | ||||
-rw-r--r-- | desktop/source/app/app.cxx | 22 | ||||
-rw-r--r-- | desktop/source/app/lockfile.cxx | 9 | ||||
-rw-r--r-- | desktop/source/app/lockfile.hxx | 3 |
4 files changed, 6 insertions, 31 deletions
diff --git a/desktop/inc/app.hxx b/desktop/inc/app.hxx index f4b00f53fc35..10f6de9dc7c3 100644 --- a/desktop/inc/app.hxx +++ b/desktop/inc/app.hxx @@ -31,6 +31,7 @@ // stl includes first #include <map> +#include <memory> #include <com/sun/star/lang/XMultiServiceFactory.hpp> #include <vcl/svapp.hxx> #include <vcl/timer.hxx> @@ -205,7 +206,7 @@ class Desktop : public Application BootstrapError m_aBootstrapError; BootstrapStatus m_aBootstrapStatus; - Lockfile *m_pLockfile; + std::auto_ptr< Lockfile > m_pLockfile; Timer m_firstRunTimer; static ResMgr* pResMgr; diff --git a/desktop/source/app/app.cxx b/desktop/source/app/app.cxx index efe2038a69ec..bf486472d25a 100644 --- a/desktop/source/app/app.cxx +++ b/desktop/source/app/app.cxx @@ -676,7 +676,6 @@ throw() Desktop::Desktop() : m_bServicesRegistered( false ) , m_aBootstrapError( BE_OK ) -, m_pLockfile( NULL ) { RTL_LOGFILE_TRACE( "desktop (cd100003) ::Desktop::Desktop" ); } @@ -797,11 +796,7 @@ void Desktop::DeInit() ::comphelper::setProcessServiceFactory( NULL ); // clear lockfile - if (m_pLockfile != NULL) - { - delete m_pLockfile; - m_pLockfile = NULL; - } + m_pLockfile.reset(); OfficeIPCThread::DisableOfficeIPCThread(); if( pSignalHandler ) @@ -862,12 +857,7 @@ sal_Bool Desktop::QueryExit() { } - if (m_pLockfile != NULL) - { - delete m_pLockfile; - m_pLockfile = NULL; - } - + m_pLockfile.reset(); } return bExit; @@ -1482,11 +1472,7 @@ sal_uInt16 Desktop::Exception(sal_uInt16 nError) default: { - if (m_pLockfile != NULL) - { - delete m_pLockfile; - m_pLockfile = NULL; - } + m_pLockfile.reset(); if( bRestart ) { @@ -1633,7 +1619,7 @@ int Desktop::Main() // check user installation directory for lockfile so we can be sure // there is no other instance using our data files from a remote host RTL_LOGFILE_CONTEXT_TRACE( aLog, "desktop (lo119109) Desktop::Main -> Lockfile" ); - m_pLockfile = new Lockfile; + m_pLockfile.reset( new Lockfile ); if ( !rCmdLineArgs.IsHeadless() && !rCmdLineArgs.IsInvisible() && !rCmdLineArgs.IsNoLockcheck() && !m_pLockfile->check( Lockfile_execWarning )) { diff --git a/desktop/source/app/lockfile.cxx b/desktop/source/app/lockfile.cxx index 72632bdb5e27..98ddb7f18cd8 100644 --- a/desktop/source/app/lockfile.cxx +++ b/desktop/source/app/lockfile.cxx @@ -210,15 +210,6 @@ namespace desktop { aConfig.Flush( ); } - void Lockfile::clean( void ) - { - if ( m_bRemove ) - { - File::remove( m_aLockname ); - m_bRemove = sal_False; - } - } - Lockfile::~Lockfile( void ) { // unlock userdata by removing file diff --git a/desktop/source/app/lockfile.hxx b/desktop/source/app/lockfile.hxx index 5444714ec88c..75a61d62c87d 100644 --- a/desktop/source/app/lockfile.hxx +++ b/desktop/source/app/lockfile.hxx @@ -73,9 +73,6 @@ namespace desktop { // found (iff gui) and returns false when we may not continue sal_Bool check( fpExecWarning execWarning ); - // removes the lockfile. should only be called in exceptional situations - void clean(void); - // removes the lockfile ~Lockfile(void); |