From 5c6c67a974aecf95dd17d8bfb570822db519a0a3 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Sat, 15 Jun 2019 17:42:47 +0200 Subject: [PATCH] [libcalamares] Destroy jobs once they have run --- src/libcalamares/JobQueue.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/libcalamares/JobQueue.cpp b/src/libcalamares/JobQueue.cpp index 07852087b..7cc6e2297 100644 --- a/src/libcalamares/JobQueue.cpp +++ b/src/libcalamares/JobQueue.cpp @@ -46,10 +46,10 @@ public: virtual ~JobThread() override; - void setJobs( const JobList& jobs ) + void setJobs( JobList&& jobs ) { m_jobs = jobs; - m_jobCount = jobs.size(); + m_jobCount = jobs.count(); } void run() override @@ -59,16 +59,18 @@ public: QString details; m_jobIndex = 0; - for( auto job : m_jobs ) + while ( !m_jobs.isEmpty() ) { + auto job = m_jobs.takeFirst(); if ( anyFailed && !job->isEmergency() ) { cDebug() << "Skipping non-emergency job" << job->prettyName(); + job.clear(); continue; } emitProgress(); - cDebug() << "Starting" << ( anyFailed ? "EMERGENCY JOB" : "job" ) << job->prettyName(); + cDebug() << "Starting" << ( anyFailed ? "EMERGENCY JOB" : "job" ) << job->prettyName() << " (there are" << m_jobs.count() << " left)"; connect( job.data(), &Job::progress, this, &JobThread::emitProgress ); JobResult result = job->exec(); if ( !anyFailed && !result ) @@ -79,6 +81,7 @@ public: } if ( !anyFailed ) ++m_jobIndex; + job.clear(); } if ( anyFailed ) emitFailed( message, details ); @@ -178,7 +181,7 @@ void JobQueue::start() { Q_ASSERT( !m_thread->isRunning() ); - m_thread->setJobs( m_jobs ); + m_thread->setJobs( std::move( m_jobs ) ); m_jobs.clear(); m_thread->start(); }