Kaydet (Commit) 3d5fde20 authored tarafından Noel Grandin's avatar Noel Grandin

loplugin:useuniqueptr in consumeScheduledThreadEntry

Change-Id: I9c0b05081915712089d363a476d6354cfba2461d
Reviewed-on: https://gerrit.libreoffice.org/59010
Tested-by: Jenkins
Reviewed-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
üst 7ec60cdc
...@@ -79,7 +79,7 @@ private: ...@@ -79,7 +79,7 @@ private:
void writeEXT( const ZipEntry &rEntry ); void writeEXT( const ZipEntry &rEntry );
// ScheduledThread handling helpers // ScheduledThread handling helpers
void consumeScheduledThreadEntry(ZipOutputEntry* pCandidate); void consumeScheduledThreadEntry(std::unique_ptr<ZipOutputEntry> pCandidate);
void consumeFinishedScheduledThreadEntries(); void consumeFinishedScheduledThreadEntries();
public: public:
......
...@@ -91,7 +91,7 @@ void ZipOutputStream::rawCloseEntry( bool bEncrypt ) ...@@ -91,7 +91,7 @@ void ZipOutputStream::rawCloseEntry( bool bEncrypt )
m_pCurrentEntry = nullptr; 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 //Any exceptions thrown in the threads were caught and stored for now
const std::exception_ptr& rCaughtException(pCandidate->getParallelDeflateException()); const std::exception_ptr& rCaughtException(pCandidate->getParallelDeflateException());
...@@ -99,7 +99,6 @@ void ZipOutputStream::consumeScheduledThreadEntry(ZipOutputEntry* pCandidate) ...@@ -99,7 +99,6 @@ void ZipOutputStream::consumeScheduledThreadEntry(ZipOutputEntry* pCandidate)
{ {
m_aDeflateException = rCaughtException; // store it for later throwing m_aDeflateException = rCaughtException; // store it for later throwing
// the exception handler in DeflateThread should have cleaned temp file // the exception handler in DeflateThread should have cleaned temp file
delete pCandidate;
return; return;
} }
...@@ -123,22 +122,21 @@ void ZipOutputStream::consumeScheduledThreadEntry(ZipOutputEntry* pCandidate) ...@@ -123,22 +122,21 @@ void ZipOutputStream::consumeScheduledThreadEntry(ZipOutputEntry* pCandidate)
pCandidate->getZipPackageStream()->successfullyWritten(pCandidate->getZipEntry()); pCandidate->getZipPackageStream()->successfullyWritten(pCandidate->getZipEntry());
pCandidate->deleteBufferFile(); pCandidate->deleteBufferFile();
delete pCandidate;
} }
void ZipOutputStream::consumeFinishedScheduledThreadEntries() void ZipOutputStream::consumeFinishedScheduledThreadEntries()
{ {
std::vector< ZipOutputEntry* > aNonFinishedEntries; 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 else
{ {
aNonFinishedEntries.push_back(*aIter); aNonFinishedEntries.push_back(pEntry);
} }
} }
...@@ -171,7 +169,7 @@ void ZipOutputStream::finish() ...@@ -171,7 +169,7 @@ void ZipOutputStream::finish()
{ {
ZipOutputEntry* pCandidate = m_aEntries.back(); ZipOutputEntry* pCandidate = m_aEntries.back();
m_aEntries.pop_back(); m_aEntries.pop_back();
consumeScheduledThreadEntry(pCandidate); consumeScheduledThreadEntry(std::unique_ptr<ZipOutputEntry>(pCandidate));
} }
sal_Int32 nOffset= static_cast < sal_Int32 > (m_aChucker.GetPosition()); sal_Int32 nOffset= static_cast < sal_Int32 > (m_aChucker.GetPosition());
......
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