Ensure that readAllStandardError() doesn't crash on assert
Ensure that it's safe to call readAllStandardError() when process channel mode is set to MergedChannels. Pick-to: 6.3 6.3.0 Task-number: QTBUG-102177 Task-number: QTCREATORBUG-27196 Change-Id: I01073255d9347dee4654d602802a12d341372b73 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>bb10
parent
5d8a7652b9
commit
b49f7e064c
|
|
@ -1942,10 +1942,16 @@ QByteArray QProcess::readAllStandardOutput()
|
|||
*/
|
||||
QByteArray QProcess::readAllStandardError()
|
||||
{
|
||||
ProcessChannel tmp = readChannel();
|
||||
setReadChannel(StandardError);
|
||||
QByteArray data = readAll();
|
||||
setReadChannel(tmp);
|
||||
Q_D(QProcess);
|
||||
QByteArray data;
|
||||
if (d->processChannelMode == MergedChannels) {
|
||||
qWarning("QProcess::readAllStandardError: Called with MergedChannels");
|
||||
} else {
|
||||
ProcessChannel tmp = readChannel();
|
||||
setReadChannel(StandardError);
|
||||
data = readAll();
|
||||
setReadChannel(tmp);
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1082,6 +1082,16 @@ void tst_QProcess::mergedChannels()
|
|||
|
||||
QVERIFY(process.waitForStarted(5000));
|
||||
|
||||
{
|
||||
QCOMPARE(process.write("abc"), qlonglong(3));
|
||||
while (process.bytesAvailable() < 6)
|
||||
QVERIFY(process.waitForReadyRead(5000));
|
||||
QCOMPARE(process.readAllStandardOutput(), QByteArray("aabbcc"));
|
||||
QTest::ignoreMessage(QtWarningMsg,
|
||||
"QProcess::readAllStandardError: Called with MergedChannels");
|
||||
QCOMPARE(process.readAllStandardError(), QByteArray());
|
||||
}
|
||||
|
||||
for (int i = 0; i < 100; ++i) {
|
||||
QCOMPARE(process.write("abc"), qlonglong(3));
|
||||
while (process.bytesAvailable() < 6)
|
||||
|
|
|
|||
Loading…
Reference in New Issue