QProcess/Unix: improve the error message if the child modifier throws

Functionality added for 6.5, but after translatable string freeze.

Change-Id: Icfe44ecf285a480fafe4fffd174d984c5349e0cb
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
This commit is contained in:
Thiago Macieira 2023-03-18 11:54:07 -07:00 committed by Volker Hilsheimer
parent ba05af82d3
commit fb40737b0d
2 changed files with 8 additions and 4 deletions

View File

@ -673,8 +673,12 @@ bool QProcessPrivate::processStarted(QString *errorMessage)
}
// did we read an error message?
if (errorMessage)
*errorMessage = QLatin1StringView(buf.function) + ": "_L1 + qt_error_string(buf.code);
if (errorMessage) {
if (buf.code == FakeErrnoForThrow)
*errorMessage = QProcess::tr("childProcessModifier() function threw an exception");
else
*errorMessage = QLatin1StringView(buf.function) + ": "_L1 + qt_error_string(buf.code);
}
return false;
}

View File

@ -1486,7 +1486,7 @@ void tst_QProcess::throwInChildProcessModifier()
QVERIFY(!process.waitForStarted(5000));
QCOMPARE(process.state(), QProcess::NotRunning);
QCOMPARE(process.error(), QProcess::FailedToStart);
QVERIFY2(process.errorString().contains("throw"),
QVERIFY2(process.errorString().contains("childProcessModifier"),
qPrintable(process.errorString()));
// try again, to ensure QProcess internal state wasn't corrupted
@ -1494,7 +1494,7 @@ void tst_QProcess::throwInChildProcessModifier()
QVERIFY(!process.waitForStarted(5000));
QCOMPARE(process.state(), QProcess::NotRunning);
QCOMPARE(process.error(), QProcess::FailedToStart);
QVERIFY2(process.errorString().contains("throw"),
QVERIFY2(process.errorString().contains("childProcessModifier"),
qPrintable(process.errorString()));
#endif
}