forked from qt-creator/qt-creator
CppCheck: Fix getting output from QtcProcess
Change-Id: Ic11d1f31afe7412ec606bdbd751deb4088d5cd3f Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -745,11 +745,6 @@ bool QtcProcess::canReadLine() const
|
|||||||
return d->m_process->canReadLine();
|
return d->m_process->canReadLine();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool QtcProcess::atEnd() const
|
|
||||||
{
|
|
||||||
return d->m_process->atEnd();
|
|
||||||
}
|
|
||||||
|
|
||||||
QString QtcProcess::locateBinary(const QString &binary)
|
QString QtcProcess::locateBinary(const QString &binary)
|
||||||
{
|
{
|
||||||
const QByteArray path = qgetenv("PATH");
|
const QByteArray path = qgetenv("PATH");
|
||||||
|
@@ -173,7 +173,6 @@ public:
|
|||||||
void close();
|
void close();
|
||||||
void setReadChannel(QProcess::ProcessChannel channel);
|
void setReadChannel(QProcess::ProcessChannel channel);
|
||||||
bool canReadLine() const;
|
bool canReadLine() const;
|
||||||
bool atEnd() const;
|
|
||||||
|
|
||||||
QIODevice *ioDevice(); // FIXME: Remove.
|
QIODevice *ioDevice(); // FIXME: Remove.
|
||||||
|
|
||||||
|
@@ -163,14 +163,14 @@ void CppcheckRunner::readOutput()
|
|||||||
if (!m_isRunning) // workaround for QTBUG-30929
|
if (!m_isRunning) // workaround for QTBUG-30929
|
||||||
handleStarted();
|
handleStarted();
|
||||||
|
|
||||||
m_process->setReadChannel(QProcess::StandardOutput);
|
const QByteArray output = m_process->readAllStandardOutput();
|
||||||
|
int start = 0;
|
||||||
while (!m_process->atEnd() && m_process->canReadLine()) {
|
int end;
|
||||||
QString line = QString::fromUtf8(m_process->readLine());
|
do {
|
||||||
if (line.endsWith('\n'))
|
end = output.indexOf('\n', start);
|
||||||
line.chop(1);
|
m_tool.parseOutputLine(QString::fromUtf8(output.mid(start, end - start)));
|
||||||
m_tool.parseOutputLine(line);
|
start = end + 1;
|
||||||
}
|
} while (end >= 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CppcheckRunner::readError()
|
void CppcheckRunner::readError()
|
||||||
@@ -178,14 +178,14 @@ void CppcheckRunner::readError()
|
|||||||
if (!m_isRunning) // workaround for QTBUG-30929
|
if (!m_isRunning) // workaround for QTBUG-30929
|
||||||
handleStarted();
|
handleStarted();
|
||||||
|
|
||||||
m_process->setReadChannel(QProcess::StandardError);
|
const QByteArray output = m_process->readAllStandardError();
|
||||||
|
int start = 0;
|
||||||
while (!m_process->atEnd() && m_process->canReadLine()) {
|
int end;
|
||||||
QString line = QString::fromUtf8(m_process->readLine());
|
do {
|
||||||
if (line.endsWith('\n'))
|
end = output.indexOf('\n', start);
|
||||||
line.chop(1);
|
m_tool.parseErrorLine(QString::fromUtf8(output.mid(start, end - start)));
|
||||||
m_tool.parseErrorLine(line);
|
start = end + 1;
|
||||||
}
|
} while (end >= 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CppcheckRunner::handleStarted()
|
void CppcheckRunner::handleStarted()
|
||||||
|
Reference in New Issue
Block a user