From be4b416e1c9e6cdcef739134ac64032055d2ee7e Mon Sep 17 00:00:00 2001 From: Konstantin Artyushkin Date: Mon, 20 Nov 2017 11:37:13 +0300 Subject: [PATCH] Check exit code of an apt-get cmd --- packageinstall/dialog.cpp | 15 ++++++++++----- packageinstall/dialog.h | 2 +- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/packageinstall/dialog.cpp b/packageinstall/dialog.cpp index 8e83583..98cca93 100644 --- a/packageinstall/dialog.cpp +++ b/packageinstall/dialog.cpp @@ -59,7 +59,7 @@ Dialog::Dialog( QStringList *p, QWidget *parent, Qt::WFlags flags ) env.replaceInStrings( QRegExp("^LC_ALL=(.*)", Qt::CaseInsensitive), "LC_ALL=C" ); process->setEnvironment( env ); - connect( process, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(processStop()) ); + connect( process, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(processStop(int, QProcess::ExitStatus)) ); connect( process, SIGNAL(readyReadStandardOutput()), this, SLOT(readOutput()) ); connect( process, SIGNAL(readyReadStandardError()), this, SLOT(readError()) ); //connect( dlg, SIGNAL(rejected()), this, SLOT(cancelPressed()) ); @@ -148,13 +148,18 @@ void Dialog::processStart() { // On finish process -void Dialog::processStop() { +void Dialog::processStop(int exitCode, QProcess::ExitStatus) { //qDebug( "processStop" ); if( d ) { - setStatus( tr("Installation is finished successful"), 100, QString( "" ) ); - d->bInstall->hide(); - d->bCancel->setText( tr("&Exit") ); + if ( exitCode != 0 ){ + setStatus( tr("ERROR: Something went wrong. Please click on the \"Show details\"!"), 0,""); + } + else { + setStatus( tr("Installation is finished successful"), 100, QString( "" ) ); + } + d->bInstall->hide(); + d->bCancel->setText( tr("&Exit") ); state = 5; } } diff --git a/packageinstall/dialog.h b/packageinstall/dialog.h index a318d6c..177b4e1 100644 --- a/packageinstall/dialog.h +++ b/packageinstall/dialog.h @@ -64,7 +64,7 @@ private slots: void readOutput(); void readError(); void windowClose(); - void processStop(); + void processStop(int, QProcess::ExitStatus); // Button actions void detailPressed(); -- 2.10.4