[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.
This commit is contained in:
Adriaan de Groot 2020-03-24 15:14:38 +01:00
parent 112895fddc
commit 184462a875
2 changed files with 15 additions and 1 deletions

View File

@ -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

View File

@ -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