diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-08-11 10:23:06 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-08-15 08:38:18 +0200 |
commit | 3d5fde2064c4c63797ba03269cd405096a2dba04 (patch) | |
tree | 0ff031aea4e277cfc5a48742c58bcf2102c29732 /package | |
parent | 7ec60cdc3a6ca76d96411288ad55435de39c4b0c (diff) |
loplugin:useuniqueptr in consumeScheduledThreadEntry
Change-Id: I9c0b05081915712089d363a476d6354cfba2461d
Reviewed-on: https://gerrit.libreoffice.org/59010
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'package')
-rw-r--r-- | package/inc/ZipOutputStream.hxx | 2 | ||||
-rw-r--r-- | package/source/zipapi/ZipOutputStream.cxx | 14 |
2 files changed, 7 insertions, 9 deletions
diff --git a/package/inc/ZipOutputStream.hxx b/package/inc/ZipOutputStream.hxx index 3f86f07883ca..814413da041e 100644 --- a/package/inc/ZipOutputStream.hxx +++ b/package/inc/ZipOutputStream.hxx @@ -79,7 +79,7 @@ private: void writeEXT( const ZipEntry &rEntry ); // ScheduledThread handling helpers - void consumeScheduledThreadEntry(ZipOutputEntry* pCandidate); + void consumeScheduledThreadEntry(std::unique_ptr<ZipOutputEntry> pCandidate); void consumeFinishedScheduledThreadEntries(); public: diff --git a/package/source/zipapi/ZipOutputStream.cxx b/package/source/zipapi/ZipOutputStream.cxx index c98876fdc6c1..8fc1f581ac49 100644 --- a/package/source/zipapi/ZipOutputStream.cxx +++ b/package/source/zipapi/ZipOutputStream.cxx @@ -91,7 +91,7 @@ void ZipOutputStream::rawCloseEntry( bool bEncrypt ) m_pCurrentEntry = nullptr; } -void ZipOutputStream::consumeScheduledThreadEntry(ZipOutputEntry* pCandidate) +void ZipOutputStream::consumeScheduledThreadEntry(std::unique_ptr<ZipOutputEntry> pCandidate) { //Any exceptions thrown in the threads were caught and stored for now const std::exception_ptr& rCaughtException(pCandidate->getParallelDeflateException()); @@ -99,7 +99,6 @@ void ZipOutputStream::consumeScheduledThreadEntry(ZipOutputEntry* pCandidate) { m_aDeflateException = rCaughtException; // store it for later throwing // the exception handler in DeflateThread should have cleaned temp file - delete pCandidate; return; } @@ -123,22 +122,21 @@ void ZipOutputStream::consumeScheduledThreadEntry(ZipOutputEntry* pCandidate) pCandidate->getZipPackageStream()->successfullyWritten(pCandidate->getZipEntry()); pCandidate->deleteBufferFile(); - delete pCandidate; } void ZipOutputStream::consumeFinishedScheduledThreadEntries() { std::vector< ZipOutputEntry* > aNonFinishedEntries; - for(auto aIter = m_aEntries.begin(); aIter != m_aEntries.end(); ++aIter) + for(ZipOutputEntry* pEntry : m_aEntries) { - if((*aIter)->isFinished()) + if(pEntry->isFinished()) { - consumeScheduledThreadEntry(*aIter); + consumeScheduledThreadEntry(std::unique_ptr<ZipOutputEntry>(pEntry)); } else { - aNonFinishedEntries.push_back(*aIter); + aNonFinishedEntries.push_back(pEntry); } } @@ -171,7 +169,7 @@ void ZipOutputStream::finish() { ZipOutputEntry* pCandidate = m_aEntries.back(); m_aEntries.pop_back(); - consumeScheduledThreadEntry(pCandidate); + consumeScheduledThreadEntry(std::unique_ptr<ZipOutputEntry>(pCandidate)); } sal_Int32 nOffset= static_cast < sal_Int32 > (m_aChucker.GetPosition()); |