# HG changeset patch # User Andre Heinecke # Date 1395399001 0 # Node ID 6090e673c707756d847eb89e9e9de251ac90ca0f # Parent e478deca18f58683c3f7e38d4c302a9b1ef04be9 Add some error handling. Change process path for testing diff -r e478deca18f5 -r 6090e673c707 ui/listupdatedialog.cpp --- a/ui/listupdatedialog.cpp Fri Mar 21 10:42:29 2014 +0000 +++ b/ui/listupdatedialog.cpp Fri Mar 21 10:50:01 2014 +0000 @@ -81,9 +81,14 @@ /* TODO move this in another dialog and call it async*/ QProcess installerProcess; - installerProcess.setProgram("cinst"); + installerProcess.setProgram("../cinst/cinst"); installerProcess.start(); installerProcess.waitForStarted(); + if (installerProcess.state() == QProcess::NotRunning) { + qWarning() << "Failed to start installer Process."; + /* TODO ERROR message for the user */ + return; + } installerProcess.write("-----BEGIN CERTIFICATE LIST-----\r\n"); installerProcess.write(mCertificateList.rawData().toLatin1()); installerProcess.write("-----END CERTIFICATE LIST-----\r\n"); @@ -98,7 +103,23 @@ installerProcess.closeWriteChannel(); installerProcess.waitForFinished(); - qDebug() << "cinst output: " << installerProcess.readAllStandardOutput(); - qDebug() << " Done " << " exitCode: " << installerProcess.exitCode(); - qDebug() << " Done " << " exitStatus: " << installerProcess.exitStatus(); + + if (installerProcess.exitStatus() == QProcess::CrashExit) { + /* Woops */ + qWarning() << "Installer process crashed"; + } else if (installerProcess.exitStatus() != QProcess::NormalExit) { + /* Can not Happen. there are only those two values but maybe + * qt changed.. */ + qWarning() << "Exit status neither normal nor crash."; + return; + } + + if (installerProcess.exitCode() == 0) { + qDebug() << "Success!"; + } else { + /* TODO handle errors defined by errorcodes.h */ + qDebug() << "Installer Process returned: " << installerProcess.exitCode(); + qDebug() << "output: " << installerProcess.readAllStandardOutput(); + return; + } }