From 184462a8758cb5eb51510a9960f90cde1451518b Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 24 Mar 2020 15:14:38 +0100 Subject: [PATCH] [libcalamares] Make status of JobQueue queryable - while the queue is executing (the thread is running jobs) the isRunning() method returns true. - re-work some internals to reset isRunning() before emitting finished() signal. --- src/libcalamares/JobQueue.cpp | 10 +++++++++- src/libcalamares/JobQueue.h | 6 ++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/libcalamares/JobQueue.cpp b/src/libcalamares/JobQueue.cpp index 209c4a416..6a2aa4cba 100644 --- a/src/libcalamares/JobQueue.cpp +++ b/src/libcalamares/JobQueue.cpp @@ -140,7 +140,7 @@ private: m_queue, "failed", Qt::QueuedConnection, Q_ARG( QString, message ), Q_ARG( QString, details ) ); } - void emitFinished() { QMetaObject::invokeMethod( m_queue, "finished", Qt::QueuedConnection ); } + void emitFinished() { QMetaObject::invokeMethod( m_queue, "finish", Qt::QueuedConnection ); } }; JobThread::~JobThread() {} @@ -195,6 +195,7 @@ JobQueue::start() Q_ASSERT( !m_thread->isRunning() ); m_thread->setJobs( std::move( m_jobs ) ); m_jobs.clear(); + m_finished = false; m_thread->start(); } @@ -216,4 +217,11 @@ JobQueue::enqueue( const JobList& jobs ) emit queueChanged( m_jobs ); } +void +JobQueue::finish() +{ + m_finished = true; + emit finished(); +} + } // namespace Calamares diff --git a/src/libcalamares/JobQueue.h b/src/libcalamares/JobQueue.h index a58b873d9..88a2bb0c3 100644 --- a/src/libcalamares/JobQueue.h +++ b/src/libcalamares/JobQueue.h @@ -45,6 +45,11 @@ public: void enqueue( const JobList& jobs ); void start(); + bool isRunning() const { return !m_finished; } + +public slots: + void finish(); + signals: void queueChanged( const JobList& jobs ); void progress( qreal percent, const QString& prettyName ); @@ -57,6 +62,7 @@ private: JobList m_jobs; JobThread* m_thread; GlobalStorage* m_storage; + bool m_finished = true; ///< Initially, not running }; } // namespace Calamares