Merge branch 'issue-1351'

FIXES #1351
This commit is contained in:
Adriaan de Groot 2020-03-24 15:32:30 +01:00
commit 938277b74e
6 changed files with 30 additions and 16 deletions

View File

@ -69,6 +69,7 @@ public:
if ( anyFailed && !job->isEmergency() ) if ( anyFailed && !job->isEmergency() )
{ {
cDebug() << "Skipping non-emergency job" << job->prettyName(); cDebug() << "Skipping non-emergency job" << job->prettyName();
++m_jobIndex;
continue; continue;
} }
@ -83,10 +84,8 @@ public:
message = result.message(); message = result.message();
details = result.details(); details = result.details();
} }
if ( !anyFailed ) emitProgress( 1.0 );
{ ++m_jobIndex;
++m_jobIndex;
}
} }
if ( anyFailed ) if ( anyFailed )
{ {
@ -141,7 +140,7 @@ private:
m_queue, "failed", Qt::QueuedConnection, Q_ARG( QString, message ), Q_ARG( QString, details ) ); 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() {} JobThread::~JobThread() {}
@ -196,6 +195,7 @@ JobQueue::start()
Q_ASSERT( !m_thread->isRunning() ); Q_ASSERT( !m_thread->isRunning() );
m_thread->setJobs( std::move( m_jobs ) ); m_thread->setJobs( std::move( m_jobs ) );
m_jobs.clear(); m_jobs.clear();
m_finished = false;
m_thread->start(); m_thread->start();
} }
@ -217,4 +217,11 @@ JobQueue::enqueue( const JobList& jobs )
emit queueChanged( m_jobs ); emit queueChanged( m_jobs );
} }
void
JobQueue::finish()
{
m_finished = true;
emit finished();
}
} // namespace Calamares } // namespace Calamares

View File

@ -45,6 +45,11 @@ public:
void enqueue( const JobList& jobs ); void enqueue( const JobList& jobs );
void start(); void start();
bool isRunning() const { return !m_finished; }
public slots:
void finish();
signals: signals:
void queueChanged( const JobList& jobs ); void queueChanged( const JobList& jobs );
void progress( qreal percent, const QString& prettyName ); void progress( qreal percent, const QString& prettyName );
@ -57,6 +62,7 @@ private:
JobList m_jobs; JobList m_jobs;
JobThread* m_thread; JobThread* m_thread;
GlobalStorage* m_storage; GlobalStorage* m_storage;
bool m_finished = true; ///< Initially, not running
}; };
} // namespace Calamares } // namespace Calamares

View File

@ -29,8 +29,8 @@
#include "utils/Paste.h" #include "utils/Paste.h"
#include "utils/Retranslator.h" #include "utils/Retranslator.h"
#include "viewpages/BlankViewStep.h" #include "viewpages/BlankViewStep.h"
#include "viewpages/ViewStep.h"
#include "viewpages/ExecutionViewStep.h" #include "viewpages/ExecutionViewStep.h"
#include "viewpages/ViewStep.h"
#include <QApplication> #include <QApplication>
#include <QBoxLayout> #include <QBoxLayout>
@ -309,6 +309,13 @@ stepIsExecute( const ViewStepList& steps, int index )
&& ( qobject_cast< ExecutionViewStep* >( steps.at( index ) ) != nullptr ); && ( 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 void
ViewManager::next() ViewManager::next()
{ {
@ -412,7 +419,7 @@ ViewManager::updateButtonLabels()
m_back->setText( tr( "&Back" ) ); m_back->setText( tr( "&Back" ) );
// Cancel button changes label at the end // Cancel button changes label at the end
if ( isAtVeryEnd() ) if ( isAtVeryEnd( m_steps, m_currentStep ) )
{ {
m_quit->setText( tr( "&Done" ) ); m_quit->setText( tr( "&Done" ) );
m_quit->setToolTip( quitOnCompleteTooltip ); m_quit->setToolTip( quitOnCompleteTooltip );
@ -473,7 +480,7 @@ ViewManager::confirmCancelInstallation()
const auto* const settings = Calamares::Settings::instance(); const auto* const settings = Calamares::Settings::instance();
// When we're at the very end, then it's always OK to exit. // When we're at the very end, then it's always OK to exit.
if ( isAtVeryEnd() ) if ( isAtVeryEnd( m_steps, m_currentStep ) )
{ {
return true; return true;
} }

View File

@ -132,12 +132,6 @@ private:
void updateButtonLabels(); void updateButtonLabels();
void updateCancelEnabled( bool enabled ); 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; static ViewManager* s_instance;
ViewStepList m_steps; ViewStepList m_steps;

View File

@ -136,7 +136,7 @@ ExecutionViewStep::isAtBeginning() const
bool bool
ExecutionViewStep::isAtEnd() const ExecutionViewStep::isAtEnd() const
{ {
return true; return !JobQueue::instance()->isRunning();
} }
void void

View File

@ -102,7 +102,7 @@ def run():
status = _("Dummy python step {}").format(str(c) + ":" + repr(k)) status = _("Dummy python step {}").format(str(c) + ":" + repr(k))
libcalamares.utils.debug(_("Dummy python step {}").format(str(k))) libcalamares.utils.debug(_("Dummy python step {}").format(str(k)))
sleep(1) sleep(1)
libcalamares.job.setprogress(c * 1.0 / len(configlist)) libcalamares.job.setprogress(c * 1.0 / (len(configlist)+1))
c += 1 c += 1
sleep(3) sleep(3)