diff --git a/src/libcalamares/JobQueue.cpp b/src/libcalamares/JobQueue.cpp index 334914828..edd437d84 100644 --- a/src/libcalamares/JobQueue.cpp +++ b/src/libcalamares/JobQueue.cpp @@ -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 ) + ); + } }; diff --git a/src/libcalamares/JobQueue.h b/src/libcalamares/JobQueue.h index 014b3d4ce..2772707be 100644 --- a/src/libcalamares/JobQueue.h +++ b/src/libcalamares/JobQueue.h @@ -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; diff --git a/src/libcalamaresui/ViewManager.cpp b/src/libcalamaresui/ViewManager.cpp index 9bdfe08ae..38ffd7494 100644 --- a/src/libcalamaresui/ViewManager.cpp +++ b/src/libcalamaresui/ViewManager.cpp @@ -23,8 +23,8 @@ #include "JobQueue.h" #include -#include #include +#include 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( + "

Installation Failed

" + "

%1

" + ).arg( message ); + + if ( !details.isEmpty() ) + { + text += tr( + "

%1

" + ).arg( details ); + } + + QMessageBox::critical( + QApplication::activeWindow(), + tr( "Error" ), + text, + QMessageBox::Close + ); + QApplication::quit(); } } diff --git a/src/libcalamaresui/ViewManager.h b/src/libcalamaresui/ViewManager.h index 9b18a1828..fd1c85c5f 100644 --- a/src/libcalamaresui/ViewManager.h +++ b/src/libcalamaresui/ViewManager.h @@ -73,6 +73,7 @@ private: void insertViewStep( int before, ViewStep* step ); void startInstallation(); + void onInstallationFailed( const QString& message, const QString& details ); }; }