Abort installation when a job fails
This commit is contained in:
parent
7894bb9462
commit
165d28fc23
@ -46,7 +46,12 @@ public:
|
||||
for( auto job : m_jobs )
|
||||
{
|
||||
emitProgress( current, total, job->prettyName() );
|
||||
job->exec();
|
||||
JobResult result = job->exec();
|
||||
if ( !result )
|
||||
{
|
||||
emitFailed( result.message(), result.details() );
|
||||
return;
|
||||
}
|
||||
++current;
|
||||
}
|
||||
emitProgress( total, total, QString() );
|
||||
@ -64,6 +69,14 @@ private:
|
||||
Q_ARG( QString, prettyName )
|
||||
);
|
||||
}
|
||||
|
||||
void emitFailed( const QString& message, const QString& details )
|
||||
{
|
||||
QMetaObject::invokeMethod( m_queue, "failed", Qt::QueuedConnection,
|
||||
Q_ARG( QString, message ),
|
||||
Q_ARG( QString, details )
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
@ -43,6 +43,7 @@ public:
|
||||
|
||||
signals:
|
||||
void progress( int current, int total, const QString& prettyName );
|
||||
void failed( const QString& message, const QString& details );
|
||||
|
||||
private:
|
||||
static JobQueue* s_instance;
|
||||
|
@ -23,8 +23,8 @@
|
||||
#include "JobQueue.h"
|
||||
|
||||
#include <QApplication>
|
||||
#include <QLabel>
|
||||
#include <QBoxLayout>
|
||||
#include <QMessageBox>
|
||||
|
||||
namespace Calamares
|
||||
{
|
||||
@ -194,11 +194,37 @@ ViewManager::back()
|
||||
void
|
||||
ViewManager::startInstallation()
|
||||
{
|
||||
JobQueue* queue = JobQueue::instance();
|
||||
for( ViewStep* step : m_prepareSteps )
|
||||
{
|
||||
JobQueue::instance()->enqueue( step->jobs() );
|
||||
queue->enqueue( step->jobs() );
|
||||
}
|
||||
JobQueue::instance()->start();
|
||||
connect( queue, &JobQueue::failed, this, &ViewManager::onInstallationFailed );
|
||||
queue->start();
|
||||
}
|
||||
|
||||
void
|
||||
ViewManager::onInstallationFailed( const QString& message, const QString& details )
|
||||
{
|
||||
QString text = tr(
|
||||
"<p><b>Installation Failed</b></p>"
|
||||
"<p>%1</p>"
|
||||
).arg( message );
|
||||
|
||||
if ( !details.isEmpty() )
|
||||
{
|
||||
text += tr(
|
||||
"<p>%1</p>"
|
||||
).arg( details );
|
||||
}
|
||||
|
||||
QMessageBox::critical(
|
||||
QApplication::activeWindow(),
|
||||
tr( "Error" ),
|
||||
text,
|
||||
QMessageBox::Close
|
||||
);
|
||||
QApplication::quit();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -73,6 +73,7 @@ private:
|
||||
|
||||
void insertViewStep( int before, ViewStep* step );
|
||||
void startInstallation();
|
||||
void onInstallationFailed( const QString& message, const QString& details );
|
||||
};
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user