forked from qt-creator/qt-creator
MsvcToolChain: Use standarized Process::exitMessage()
Instead of the own exit message construction. Change-Id: Id1760f7341c59cff807a48757e0f82d22fb43dd3 Reviewed-by: Orgad Shaneh <orgads@gmail.com> Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
@@ -256,33 +256,16 @@ static QVector<VisualStudioInstallation> detectVisualStudioFromVsWhere(const QSt
|
|||||||
QVector<VisualStudioInstallation> installations;
|
QVector<VisualStudioInstallation> installations;
|
||||||
Process vsWhereProcess;
|
Process vsWhereProcess;
|
||||||
vsWhereProcess.setCodec(QTextCodec::codecForName("UTF-8"));
|
vsWhereProcess.setCodec(QTextCodec::codecForName("UTF-8"));
|
||||||
const int timeoutS = 5;
|
vsWhereProcess.setTimeoutS(5);
|
||||||
vsWhereProcess.setTimeoutS(timeoutS);
|
|
||||||
vsWhereProcess.setCommand({FilePath::fromString(vswhere),
|
vsWhereProcess.setCommand({FilePath::fromString(vswhere),
|
||||||
{"-products", "*", "-prerelease", "-legacy", "-format", "json", "-utf8"}});
|
{"-products", "*", "-prerelease", "-legacy", "-format", "json", "-utf8"}});
|
||||||
vsWhereProcess.runBlocking();
|
vsWhereProcess.runBlocking();
|
||||||
switch (vsWhereProcess.result()) {
|
if (vsWhereProcess.result() != ProcessResult::FinishedWithSuccess) {
|
||||||
case ProcessResult::FinishedWithSuccess:
|
qWarning() << vsWhereProcess.exitMessage();
|
||||||
break;
|
|
||||||
case ProcessResult::StartFailed:
|
|
||||||
qWarning().noquote() << QDir::toNativeSeparators(vswhere) << "could not be started.";
|
|
||||||
return installations;
|
|
||||||
case ProcessResult::FinishedWithError:
|
|
||||||
qWarning().noquote().nospace() << QDir::toNativeSeparators(vswhere)
|
|
||||||
<< " finished with exit code "
|
|
||||||
<< vsWhereProcess.exitCode() << ".";
|
|
||||||
return installations;
|
|
||||||
case ProcessResult::TerminatedAbnormally:
|
|
||||||
qWarning().noquote().nospace()
|
|
||||||
<< QDir::toNativeSeparators(vswhere) << " crashed. Exit code: " << vsWhereProcess.exitCode();
|
|
||||||
return installations;
|
|
||||||
case ProcessResult::Hang:
|
|
||||||
qWarning().noquote() << QDir::toNativeSeparators(vswhere) << "did not finish in" << timeoutS
|
|
||||||
<< "seconds.";
|
|
||||||
return installations;
|
return installations;
|
||||||
}
|
}
|
||||||
|
|
||||||
QByteArray output = vsWhereProcess.cleanedStdOut().toUtf8();
|
const QByteArray output = vsWhereProcess.cleanedStdOut().toUtf8();
|
||||||
QJsonParseError error;
|
QJsonParseError error;
|
||||||
const QJsonDocument doc = QJsonDocument::fromJson(output, &error);
|
const QJsonDocument doc = QJsonDocument::fromJson(output, &error);
|
||||||
if (error.error != QJsonParseError::NoError || doc.isNull()) {
|
if (error.error != QJsonParseError::NoError || doc.isNull()) {
|
||||||
|
Reference in New Issue
Block a user