From 1ec72512757f829c425fd6ecac9d0133eea592dd Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 24 Mar 2020 14:23:37 +0100 Subject: [PATCH 1/5] [libcalamares] Make isAtVeryEnd() internal --- src/libcalamaresui/ViewManager.cpp | 13 ++++++++++--- src/libcalamaresui/ViewManager.h | 6 ------ 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/libcalamaresui/ViewManager.cpp b/src/libcalamaresui/ViewManager.cpp index 96d4cc3a0..6ee0d5de3 100644 --- a/src/libcalamaresui/ViewManager.cpp +++ b/src/libcalamaresui/ViewManager.cpp @@ -29,8 +29,8 @@ #include "utils/Paste.h" #include "utils/Retranslator.h" #include "viewpages/BlankViewStep.h" -#include "viewpages/ViewStep.h" #include "viewpages/ExecutionViewStep.h" +#include "viewpages/ViewStep.h" #include #include @@ -309,6 +309,13 @@ stepIsExecute( const ViewStepList& steps, int index ) && ( qobject_cast< ExecutionViewStep* >( steps.at( index ) ) != nullptr ); } +static inline bool +isAtVeryEnd( const ViewStepList& steps, int index ) + +{ + return ( index >= steps.count() ) || ( index == steps.count() - 1 && steps.last()->isAtEnd() ); +} + void ViewManager::next() { @@ -412,7 +419,7 @@ ViewManager::updateButtonLabels() m_back->setText( tr( "&Back" ) ); // Cancel button changes label at the end - if ( isAtVeryEnd() ) + if ( isAtVeryEnd( m_steps, m_currentStep ) ) { m_quit->setText( tr( "&Done" ) ); m_quit->setToolTip( quitOnCompleteTooltip ); @@ -473,7 +480,7 @@ ViewManager::confirmCancelInstallation() const auto* const settings = Calamares::Settings::instance(); // When we're at the very end, then it's always OK to exit. - if ( isAtVeryEnd() ) + if ( isAtVeryEnd( m_steps, m_currentStep ) ) { return true; } diff --git a/src/libcalamaresui/ViewManager.h b/src/libcalamaresui/ViewManager.h index 7ca6eb377..a4bedd7bc 100644 --- a/src/libcalamaresui/ViewManager.h +++ b/src/libcalamaresui/ViewManager.h @@ -132,12 +132,6 @@ private: void updateButtonLabels(); void updateCancelEnabled( bool enabled ); - bool isAtVeryEnd() const - { - return ( m_currentStep >= m_steps.count() ) - || ( m_currentStep == m_steps.count() - 1 && m_steps.last()->isAtEnd() ); - } - static ViewManager* s_instance; ViewStepList m_steps; From 112895fddc8ab4827868d9d07ec692a68963f87e Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 24 Mar 2020 15:06:34 +0100 Subject: [PATCH 2/5] [libcalamares] Keep jobIndex in-sync with the jobs - Never skip updating the jobIndex, because it is used in emitProgress() to find which job to ask for status. --- src/libcalamares/JobQueue.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/libcalamares/JobQueue.cpp b/src/libcalamares/JobQueue.cpp index cf9d9ad65..209c4a416 100644 --- a/src/libcalamares/JobQueue.cpp +++ b/src/libcalamares/JobQueue.cpp @@ -69,6 +69,7 @@ public: if ( anyFailed && !job->isEmergency() ) { cDebug() << "Skipping non-emergency job" << job->prettyName(); + ++m_jobIndex; continue; } @@ -83,10 +84,8 @@ public: message = result.message(); details = result.details(); } - if ( !anyFailed ) - { - ++m_jobIndex; - } + emitProgress( 1.0 ); + ++m_jobIndex; } if ( anyFailed ) { From 184462a8758cb5eb51510a9960f90cde1451518b Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 24 Mar 2020 15:14:38 +0100 Subject: [PATCH 3/5] [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 From 1d30c99d89515ccd06bdaa8b8adac75638608636 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 24 Mar 2020 15:19:45 +0100 Subject: [PATCH 4/5] [libcalamaresui] The ExecutionViewStep is done when the queue is - While the queue is running, pretend that the EVS is not at the last page. FIXES #1351 --- src/libcalamaresui/viewpages/ExecutionViewStep.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libcalamaresui/viewpages/ExecutionViewStep.cpp b/src/libcalamaresui/viewpages/ExecutionViewStep.cpp index 8ea918690..c9bc4b8c3 100644 --- a/src/libcalamaresui/viewpages/ExecutionViewStep.cpp +++ b/src/libcalamaresui/viewpages/ExecutionViewStep.cpp @@ -136,7 +136,7 @@ ExecutionViewStep::isAtBeginning() const bool ExecutionViewStep::isAtEnd() const { - return true; + return !JobQueue::instance()->isRunning(); } void From 71b55995ee8a31da2b6ecd80a337ac7edea06230 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 24 Mar 2020 15:23:40 +0100 Subject: [PATCH 5/5] [dummypython] Fix up progress reporting - It's annoying to have 100% progress reported (from the processing of list items) and then have another 3 seconds delay. Unrelated to the issue-at-hand, but spotted in testing. --- src/modules/dummypython/main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/dummypython/main.py b/src/modules/dummypython/main.py index 2da9b4760..96de6030f 100644 --- a/src/modules/dummypython/main.py +++ b/src/modules/dummypython/main.py @@ -102,7 +102,7 @@ def run(): status = _("Dummy python step {}").format(str(c) + ":" + repr(k)) libcalamares.utils.debug(_("Dummy python step {}").format(str(k))) sleep(1) - libcalamares.job.setprogress(c * 1.0 / len(configlist)) + libcalamares.job.setprogress(c * 1.0 / (len(configlist)+1)) c += 1 sleep(3)