summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2015-07-21 14:53:27 +0100
committerCaolán McNamara <caolanm@redhat.com>2015-07-21 14:58:30 +0100
commit0d312afe2d31c19dbd2388d17ddbb372d1197c1f (patch)
tree53ec682a082a02d369231cff601e0e5d129fb9f4
parent289e5dbbab58410dac59534c79ebe831a7712129 (diff)
coverity#1312087 Resource leak
Change-Id: I6d526440bd652dcd1745b8d84ff69855691d7e48
-rw-r--r--svtools/source/contnr/fileview.cxx46
-rw-r--r--svtools/source/contnr/foldertree.cxx7
2 files changed, 27 insertions, 26 deletions
diff --git a/svtools/source/contnr/fileview.cxx b/svtools/source/contnr/fileview.cxx
index 10fa19fac992..c85b1dd8430f 100644
--- a/svtools/source/contnr/fileview.cxx
+++ b/svtools/source/contnr/fileview.cxx
@@ -421,10 +421,10 @@ protected:
Link<> m_aSelectHandler;
::rtl::Reference< ::svt::FileViewContentEnumerator >
- m_pContentEnumerator;
+ m_xContentEnumerator;
Link<> m_aCurrentAsyncActionHandler;
::osl::Condition m_aAsyncActionFinished;
- ::rtl::Reference< ::salhelper::Timer > m_pCancelAsyncTimer;
+ ::rtl::Reference< ::salhelper::Timer > m_xCancelAsyncTimer;
::svt::EnumerationResult m_eAsyncActionResult;
bool m_bRunningAsyncAction;
bool m_bAsyncActionCancelled;
@@ -1639,21 +1639,21 @@ FileViewResult SvtFileView_Impl::GetFolderContent_Impl(
DBG_TESTSOLARMUTEX();
::osl::ClearableMutexGuard aGuard( maMutex );
- OSL_ENSURE( !m_pContentEnumerator.is(), "SvtFileView_Impl::GetFolderContent_Impl: still running another enumeration!" );
- m_pContentEnumerator = new ::svt::FileViewContentEnumerator(
- mpView->GetCommandEnvironment(), maContent, maMutex, mbReplaceNames ? mpNameTrans : NULL );
+ OSL_ENSURE( !m_xContentEnumerator.is(), "SvtFileView_Impl::GetFolderContent_Impl: still running another enumeration!" );
+ m_xContentEnumerator.set(new ::svt::FileViewContentEnumerator(
+ mpView->GetCommandEnvironment(), maContent, maMutex, mbReplaceNames ? mpNameTrans : NULL));
// TODO: should we cache and re-use this thread?
if ( !pAsyncDescriptor )
{
- ::svt::EnumerationResult eResult = m_pContentEnumerator->enumerateFolderContentSync( _rFolder, rBlackList );
+ ::svt::EnumerationResult eResult = m_xContentEnumerator->enumerateFolderContentSync( _rFolder, rBlackList );
if ( ::svt::SUCCESS == eResult )
{
implEnumerationSuccess();
- m_pContentEnumerator.clear();
+ m_xContentEnumerator.clear();
return eSuccess;
}
- m_pContentEnumerator.clear();
+ m_xContentEnumerator.clear();
return eFailure;
}
@@ -1676,7 +1676,7 @@ FileViewResult SvtFileView_Impl::GetFolderContent_Impl(
pTimeout->Seconds = nMinTimeout / 1000L;
pTimeout->Nanosec = ( nMinTimeout % 1000L ) * 1000000L;
- m_pContentEnumerator->enumerateFolderContent( _rFolder, this );
+ m_xContentEnumerator->enumerateFolderContent( _rFolder, this );
// wait until the enumeration is finished
// for this, release our own mutex (which is used by the enumerator thread)
@@ -1697,16 +1697,16 @@ FileViewResult SvtFileView_Impl::GetFolderContent_Impl(
if ( ::osl::Condition::result_timeout == eResult )
{
// maximum time to wait
- OSL_ENSURE( !m_pCancelAsyncTimer.get(), "SvtFileView_Impl::GetFolderContent_Impl: there's still a previous timer!" );
- m_pCancelAsyncTimer = new CallbackTimer( this );
+ OSL_ENSURE( !m_xCancelAsyncTimer.get(), "SvtFileView_Impl::GetFolderContent_Impl: there's still a previous timer!" );
+ m_xCancelAsyncTimer.set(new CallbackTimer(this));
sal_Int32 nMaxTimeout = pAsyncDescriptor->nMaxTimeout;
OSL_ENSURE( nMaxTimeout > nMinTimeout,
"SvtFileView_Impl::GetFolderContent_Impl: invalid maximum timeout!" );
if ( nMaxTimeout <= nMinTimeout )
nMaxTimeout = nMinTimeout + 5000;
- m_pCancelAsyncTimer->setRemainingTime( salhelper::TTimeValue( nMaxTimeout - nMinTimeout ) );
+ m_xCancelAsyncTimer->setRemainingTime( salhelper::TTimeValue( nMaxTimeout - nMinTimeout ) );
// we already waited for nMinTimeout milliseconds, so take this into account
- m_pCancelAsyncTimer->start();
+ m_xCancelAsyncTimer->start();
m_aCurrentAsyncActionHandler = pAsyncDescriptor->aFinishHandler;
DBG_ASSERT( m_aCurrentAsyncActionHandler.IsSet(), "SvtFileView_Impl::GetFolderContent_Impl: nobody interested when it's finished?" );
@@ -1897,17 +1897,17 @@ void SvtFileView_Impl::CancelRunningAsyncAction()
{
DBG_TESTSOLARMUTEX();
::osl::MutexGuard aGuard( maMutex );
- if ( !m_pContentEnumerator.is() )
+ if ( !m_xContentEnumerator.is() )
return;
m_bAsyncActionCancelled = true;
- m_pContentEnumerator->cancel();
+ m_xContentEnumerator->cancel();
m_bRunningAsyncAction = false;
- m_pContentEnumerator.clear();
- if ( m_pCancelAsyncTimer.is() && m_pCancelAsyncTimer->isTicking() )
- m_pCancelAsyncTimer->stop();
- m_pCancelAsyncTimer = NULL;
+ m_xContentEnumerator.clear();
+ if ( m_xCancelAsyncTimer.is() && m_xCancelAsyncTimer->isTicking() )
+ m_xCancelAsyncTimer->stop();
+ m_xCancelAsyncTimer.clear();
}
@@ -1934,10 +1934,10 @@ void SvtFileView_Impl::enumerationDone( ::svt::EnumerationResult eResult )
SolarMutexGuard aSolarGuard;
::osl::MutexGuard aGuard( maMutex );
- m_pContentEnumerator.clear();
- if ( m_pCancelAsyncTimer.is() && m_pCancelAsyncTimer->isTicking() )
- m_pCancelAsyncTimer->stop();
- m_pCancelAsyncTimer = NULL;
+ m_xContentEnumerator.clear();
+ if ( m_xCancelAsyncTimer.is() && m_xCancelAsyncTimer->isTicking() )
+ m_xCancelAsyncTimer->stop();
+ m_xCancelAsyncTimer.clear();
if ( m_bAsyncActionCancelled )
// this is to prevent race conditions
diff --git a/svtools/source/contnr/foldertree.cxx b/svtools/source/contnr/foldertree.cxx
index 5c8ee462705c..50df76b9ae63 100644
--- a/svtools/source/contnr/foldertree.cxx
+++ b/svtools/source/contnr/foldertree.cxx
@@ -36,8 +36,9 @@ void FolderTree::FillTreeEntry( SvTreeListEntry* pEntry )
{
::std::vector< SortingData_Impl* > aContent;
- FileViewContentEnumerator* pContentEnumerator = new FileViewContentEnumerator(
- m_xEnv, aContent, m_aMutex, NULL );
+ ::rtl::Reference< ::svt::FileViewContentEnumerator >
+ xContentEnumerator(new FileViewContentEnumerator(
+ m_xEnv, aContent, m_aMutex, NULL));
OUString* pURL = static_cast< OUString* >( pEntry->GetUserData() );
@@ -46,7 +47,7 @@ void FolderTree::FillTreeEntry( SvTreeListEntry* pEntry )
FolderDescriptor aFolder( *pURL );
EnumerationResult eResult =
- pContentEnumerator->enumerateFolderContentSync( aFolder, m_aBlackList );
+ xContentEnumerator->enumerateFolderContentSync( aFolder, m_aBlackList );
if ( SUCCESS == eResult )
{