Kaydet (Commit) 0d312afe authored tarafından Caolán McNamara's avatar Caolán McNamara

coverity#1312087 Resource leak

Change-Id: I6d526440bd652dcd1745b8d84ff69855691d7e48
üst 289e5dbb
...@@ -421,10 +421,10 @@ protected: ...@@ -421,10 +421,10 @@ protected:
Link<> m_aSelectHandler; Link<> m_aSelectHandler;
::rtl::Reference< ::svt::FileViewContentEnumerator > ::rtl::Reference< ::svt::FileViewContentEnumerator >
m_pContentEnumerator; m_xContentEnumerator;
Link<> m_aCurrentAsyncActionHandler; Link<> m_aCurrentAsyncActionHandler;
::osl::Condition m_aAsyncActionFinished; ::osl::Condition m_aAsyncActionFinished;
::rtl::Reference< ::salhelper::Timer > m_pCancelAsyncTimer; ::rtl::Reference< ::salhelper::Timer > m_xCancelAsyncTimer;
::svt::EnumerationResult m_eAsyncActionResult; ::svt::EnumerationResult m_eAsyncActionResult;
bool m_bRunningAsyncAction; bool m_bRunningAsyncAction;
bool m_bAsyncActionCancelled; bool m_bAsyncActionCancelled;
...@@ -1639,21 +1639,21 @@ FileViewResult SvtFileView_Impl::GetFolderContent_Impl( ...@@ -1639,21 +1639,21 @@ FileViewResult SvtFileView_Impl::GetFolderContent_Impl(
DBG_TESTSOLARMUTEX(); DBG_TESTSOLARMUTEX();
::osl::ClearableMutexGuard aGuard( maMutex ); ::osl::ClearableMutexGuard aGuard( maMutex );
OSL_ENSURE( !m_pContentEnumerator.is(), "SvtFileView_Impl::GetFolderContent_Impl: still running another enumeration!" ); OSL_ENSURE( !m_xContentEnumerator.is(), "SvtFileView_Impl::GetFolderContent_Impl: still running another enumeration!" );
m_pContentEnumerator = new ::svt::FileViewContentEnumerator( m_xContentEnumerator.set(new ::svt::FileViewContentEnumerator(
mpView->GetCommandEnvironment(), maContent, maMutex, mbReplaceNames ? mpNameTrans : NULL ); mpView->GetCommandEnvironment(), maContent, maMutex, mbReplaceNames ? mpNameTrans : NULL));
// TODO: should we cache and re-use this thread? // TODO: should we cache and re-use this thread?
if ( !pAsyncDescriptor ) if ( !pAsyncDescriptor )
{ {
::svt::EnumerationResult eResult = m_pContentEnumerator->enumerateFolderContentSync( _rFolder, rBlackList ); ::svt::EnumerationResult eResult = m_xContentEnumerator->enumerateFolderContentSync( _rFolder, rBlackList );
if ( ::svt::SUCCESS == eResult ) if ( ::svt::SUCCESS == eResult )
{ {
implEnumerationSuccess(); implEnumerationSuccess();
m_pContentEnumerator.clear(); m_xContentEnumerator.clear();
return eSuccess; return eSuccess;
} }
m_pContentEnumerator.clear(); m_xContentEnumerator.clear();
return eFailure; return eFailure;
} }
...@@ -1676,7 +1676,7 @@ FileViewResult SvtFileView_Impl::GetFolderContent_Impl( ...@@ -1676,7 +1676,7 @@ FileViewResult SvtFileView_Impl::GetFolderContent_Impl(
pTimeout->Seconds = nMinTimeout / 1000L; pTimeout->Seconds = nMinTimeout / 1000L;
pTimeout->Nanosec = ( nMinTimeout % 1000L ) * 1000000L; pTimeout->Nanosec = ( nMinTimeout % 1000L ) * 1000000L;
m_pContentEnumerator->enumerateFolderContent( _rFolder, this ); m_xContentEnumerator->enumerateFolderContent( _rFolder, this );
// wait until the enumeration is finished // wait until the enumeration is finished
// for this, release our own mutex (which is used by the enumerator thread) // for this, release our own mutex (which is used by the enumerator thread)
...@@ -1697,16 +1697,16 @@ FileViewResult SvtFileView_Impl::GetFolderContent_Impl( ...@@ -1697,16 +1697,16 @@ FileViewResult SvtFileView_Impl::GetFolderContent_Impl(
if ( ::osl::Condition::result_timeout == eResult ) if ( ::osl::Condition::result_timeout == eResult )
{ {
// maximum time to wait // maximum time to wait
OSL_ENSURE( !m_pCancelAsyncTimer.get(), "SvtFileView_Impl::GetFolderContent_Impl: there's still a previous timer!" ); OSL_ENSURE( !m_xCancelAsyncTimer.get(), "SvtFileView_Impl::GetFolderContent_Impl: there's still a previous timer!" );
m_pCancelAsyncTimer = new CallbackTimer( this ); m_xCancelAsyncTimer.set(new CallbackTimer(this));
sal_Int32 nMaxTimeout = pAsyncDescriptor->nMaxTimeout; sal_Int32 nMaxTimeout = pAsyncDescriptor->nMaxTimeout;
OSL_ENSURE( nMaxTimeout > nMinTimeout, OSL_ENSURE( nMaxTimeout > nMinTimeout,
"SvtFileView_Impl::GetFolderContent_Impl: invalid maximum timeout!" ); "SvtFileView_Impl::GetFolderContent_Impl: invalid maximum timeout!" );
if ( nMaxTimeout <= nMinTimeout ) if ( nMaxTimeout <= nMinTimeout )
nMaxTimeout = nMinTimeout + 5000; 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 // we already waited for nMinTimeout milliseconds, so take this into account
m_pCancelAsyncTimer->start(); m_xCancelAsyncTimer->start();
m_aCurrentAsyncActionHandler = pAsyncDescriptor->aFinishHandler; m_aCurrentAsyncActionHandler = pAsyncDescriptor->aFinishHandler;
DBG_ASSERT( m_aCurrentAsyncActionHandler.IsSet(), "SvtFileView_Impl::GetFolderContent_Impl: nobody interested when it's finished?" ); DBG_ASSERT( m_aCurrentAsyncActionHandler.IsSet(), "SvtFileView_Impl::GetFolderContent_Impl: nobody interested when it's finished?" );
...@@ -1897,17 +1897,17 @@ void SvtFileView_Impl::CancelRunningAsyncAction() ...@@ -1897,17 +1897,17 @@ void SvtFileView_Impl::CancelRunningAsyncAction()
{ {
DBG_TESTSOLARMUTEX(); DBG_TESTSOLARMUTEX();
::osl::MutexGuard aGuard( maMutex ); ::osl::MutexGuard aGuard( maMutex );
if ( !m_pContentEnumerator.is() ) if ( !m_xContentEnumerator.is() )
return; return;
m_bAsyncActionCancelled = true; m_bAsyncActionCancelled = true;
m_pContentEnumerator->cancel(); m_xContentEnumerator->cancel();
m_bRunningAsyncAction = false; m_bRunningAsyncAction = false;
m_pContentEnumerator.clear(); m_xContentEnumerator.clear();
if ( m_pCancelAsyncTimer.is() && m_pCancelAsyncTimer->isTicking() ) if ( m_xCancelAsyncTimer.is() && m_xCancelAsyncTimer->isTicking() )
m_pCancelAsyncTimer->stop(); m_xCancelAsyncTimer->stop();
m_pCancelAsyncTimer = NULL; m_xCancelAsyncTimer.clear();
} }
...@@ -1934,10 +1934,10 @@ void SvtFileView_Impl::enumerationDone( ::svt::EnumerationResult eResult ) ...@@ -1934,10 +1934,10 @@ void SvtFileView_Impl::enumerationDone( ::svt::EnumerationResult eResult )
SolarMutexGuard aSolarGuard; SolarMutexGuard aSolarGuard;
::osl::MutexGuard aGuard( maMutex ); ::osl::MutexGuard aGuard( maMutex );
m_pContentEnumerator.clear(); m_xContentEnumerator.clear();
if ( m_pCancelAsyncTimer.is() && m_pCancelAsyncTimer->isTicking() ) if ( m_xCancelAsyncTimer.is() && m_xCancelAsyncTimer->isTicking() )
m_pCancelAsyncTimer->stop(); m_xCancelAsyncTimer->stop();
m_pCancelAsyncTimer = NULL; m_xCancelAsyncTimer.clear();
if ( m_bAsyncActionCancelled ) if ( m_bAsyncActionCancelled )
// this is to prevent race conditions // this is to prevent race conditions
......
...@@ -36,8 +36,9 @@ void FolderTree::FillTreeEntry( SvTreeListEntry* pEntry ) ...@@ -36,8 +36,9 @@ void FolderTree::FillTreeEntry( SvTreeListEntry* pEntry )
{ {
::std::vector< SortingData_Impl* > aContent; ::std::vector< SortingData_Impl* > aContent;
FileViewContentEnumerator* pContentEnumerator = new FileViewContentEnumerator( ::rtl::Reference< ::svt::FileViewContentEnumerator >
m_xEnv, aContent, m_aMutex, NULL ); xContentEnumerator(new FileViewContentEnumerator(
m_xEnv, aContent, m_aMutex, NULL));
OUString* pURL = static_cast< OUString* >( pEntry->GetUserData() ); OUString* pURL = static_cast< OUString* >( pEntry->GetUserData() );
...@@ -46,7 +47,7 @@ void FolderTree::FillTreeEntry( SvTreeListEntry* pEntry ) ...@@ -46,7 +47,7 @@ void FolderTree::FillTreeEntry( SvTreeListEntry* pEntry )
FolderDescriptor aFolder( *pURL ); FolderDescriptor aFolder( *pURL );
EnumerationResult eResult = EnumerationResult eResult =
pContentEnumerator->enumerateFolderContentSync( aFolder, m_aBlackList ); xContentEnumerator->enumerateFolderContentSync( aFolder, m_aBlackList );
if ( SUCCESS == eResult ) if ( SUCCESS == eResult )
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment