forked from qt-creator/qt-creator
Android: Properly split stderr into lines and drop unrelated messages
Change-Id: I860cddcea23692fd8c9b69b849e7b1fb50e9113d Reviewed-by: Daniel Teske <daniel.teske@digia.com>
This commit is contained in:
@@ -351,24 +351,17 @@ void AndroidRunner::stop()
|
||||
m_adbLogcatProcess.waitForFinished();
|
||||
}
|
||||
|
||||
void AndroidRunner::logcatReadStandardError()
|
||||
void AndroidRunner::logcatProcess(const QByteArray &text, QByteArray &buffer, bool onlyError)
|
||||
{
|
||||
emit remoteErrorOutput(m_adbLogcatProcess.readAllStandardError());
|
||||
}
|
||||
|
||||
void AndroidRunner::logcatReadStandardOutput()
|
||||
{
|
||||
if (m_processPID == -1)
|
||||
return;
|
||||
QList<QByteArray> lines = m_adbLogcatProcess.readAllStandardOutput().split('\n');
|
||||
QList<QByteArray> lines = text.split('\n');
|
||||
// lines always contains at least one item
|
||||
lines[0].prepend(m_logcat);
|
||||
lines[0].prepend(buffer);
|
||||
if (!lines.last().endsWith('\n')) {
|
||||
// incomplete line
|
||||
m_logcat = lines.last();
|
||||
buffer = lines.last();
|
||||
lines.removeLast();
|
||||
} else {
|
||||
m_logcat.clear();
|
||||
buffer.clear();
|
||||
}
|
||||
|
||||
QByteArray pid(QString::fromLatin1("%1):").arg(m_processPID).toLatin1());
|
||||
@@ -378,7 +371,7 @@ void AndroidRunner::logcatReadStandardOutput()
|
||||
if (line.endsWith('\r'))
|
||||
line.chop(1);
|
||||
line.append('\n');
|
||||
if (line.startsWith("E/")
|
||||
if (onlyError || line.startsWith("E/")
|
||||
|| line.startsWith("D/Qt")
|
||||
|| line.startsWith("W/"))
|
||||
emit remoteErrorOutput(line);
|
||||
@@ -388,6 +381,18 @@ void AndroidRunner::logcatReadStandardOutput()
|
||||
}
|
||||
}
|
||||
|
||||
void AndroidRunner::logcatReadStandardError()
|
||||
{
|
||||
if (m_processPID != -1)
|
||||
logcatProcess(m_adbLogcatProcess.readAllStandardError(), m_stderrBuffer, true);
|
||||
}
|
||||
|
||||
void AndroidRunner::logcatReadStandardOutput()
|
||||
{
|
||||
if (m_processPID != -1)
|
||||
logcatProcess(m_adbLogcatProcess.readAllStandardOutput(), m_stdoutBuffer, false);
|
||||
}
|
||||
|
||||
void AndroidRunner::adbKill(qint64 pid)
|
||||
{
|
||||
{
|
||||
|
||||
@@ -82,6 +82,7 @@ private:
|
||||
void forceStop();
|
||||
QByteArray runPs();
|
||||
void findPs();
|
||||
void logcatProcess(const QByteArray &text, QByteArray &buffer, bool onlyError);
|
||||
|
||||
private:
|
||||
QProcess m_adbLogcatProcess;
|
||||
@@ -89,7 +90,8 @@ private:
|
||||
bool m_wasStarted;
|
||||
int m_tries;
|
||||
|
||||
QByteArray m_logcat;
|
||||
QByteArray m_stdoutBuffer;
|
||||
QByteArray m_stderrBuffer;
|
||||
QString m_intentName;
|
||||
QString m_packageName;
|
||||
QString m_deviceSerialNumber;
|
||||
|
||||
Reference in New Issue
Block a user