Merge branch 'fix-debugwindow-queue' into calamares

3.2.29 dropped the Job Queue information from the debug
window, this restores the list of names.
This commit is contained in:
Adriaan de Groot 2020-08-28 15:54:13 +02:00
commit ba2b52ed1d
3 changed files with 57 additions and 17 deletions

View File

@ -93,14 +93,8 @@ DebugWindow::DebugWindow()
// JobQueue page
m_ui->jobQueueText->setReadOnly( true );
connect( JobQueue::instance(), &JobQueue::queueChanged, this, [this]( const JobList& jobs ) {
QStringList text;
for ( const auto& job : jobs )
{
text.append( job->prettyName() );
}
m_ui->jobQueueText->setText( text.join( '\n' ) );
connect( JobQueue::instance(), &JobQueue::queueChanged, this, [this]( const QStringList& jobs ) {
m_ui->jobQueueText->setText( jobs.join( '\n' ) );
} );
// Modules page

View File

@ -138,6 +138,24 @@ public:
QMetaObject::invokeMethod( m_queue, "finish", Qt::QueuedConnection );
}
/** @brief The names of the queued (not running!) jobs.
*/
QStringList queuedJobs() const
{
QMutexLocker qlock( &m_enqueMutex );
QStringList l;
l.reserve( m_queuedJobs->count() );
for ( const auto& j : *m_queuedJobs )
{
l << j.job->prettyName();
}
return l;
}
private:
/* This is called **only** from run(), while m_runMutex is
* already locked, so we can use the m_runningJobs member safely.
*/
void emitProgress( qreal percentage ) const
{
percentage = qBound( 0.0, percentage, 1.0 );
@ -159,10 +177,8 @@ public:
m_queue, "progress", Qt::QueuedConnection, Q_ARG( qreal, progress ), Q_ARG( QString, message ) );
}
private:
QMutex m_runMutex;
QMutex m_enqueMutex;
mutable QMutex m_runMutex;
mutable QMutex m_enqueMutex;
std::unique_ptr< WeightedJobList > m_runningJobs = std::make_unique< WeightedJobList >();
std::unique_ptr< WeightedJobList > m_queuedJobs = std::make_unique< WeightedJobList >();
@ -229,7 +245,7 @@ JobQueue::enqueue( int moduleWeight, const JobList& jobs )
{
Q_ASSERT( !m_thread->isRunning() );
m_thread->enqueue( moduleWeight, jobs );
emit queueChanged( jobs ); // FIXME: bogus
emit queueChanged( m_thread->queuedJobs() );
}
void
@ -237,6 +253,7 @@ JobQueue::finish()
{
m_finished = true;
emit finished();
emit queueChanged( m_thread->queuedJobs() );
}
GlobalStorage*

View File

@ -37,20 +37,49 @@ public:
* of the module.
*/
void enqueue( int moduleWeight, const JobList& jobs );
/** @brief Starts all the jobs that are enqueued.
*
* After this, isRunning() returns @c true until
* finished() is emitted.
*/
void start();
bool isRunning() const { return !m_finished; }
public slots:
void finish();
signals:
void queueChanged( const JobList& jobs );
/** @brief Report progress of the whole queue, with a status message
*
* The @p percent is a value between 0.0 and 1.0 (100%) of the
* overall queue progress (not of the current job), while
* @p prettyName is the status message from the job -- often
* just the name of the job, but some jobs include more information.
*/
void progress( qreal percent, const QString& prettyName );
/** @brief Indicate that the queue is empty, after calling start()
*
* Emitted when the queue empties. The queue may also emit
* failed(), if something went wrong, but finished() is always
* the last one.
*/
void finished();
/** @brief A job in the queue failed.
*
* Contains the (already-translated) text from the job describing
* the failure.
*/
void failed( const QString& message, const QString& details );
/** @brief Reports the names of jobs in the queue.
*
* When jobs are added via enqueue(), or when the queue otherwise
* changes, the **names** of the jobs are reported. This is
* primarily for debugging purposes.
*/
void queueChanged( const QStringList& jobNames );
private:
void finish();
static JobQueue* s_instance;
JobThread* m_thread;