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();
|
m_adbLogcatProcess.waitForFinished();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AndroidRunner::logcatReadStandardError()
|
void AndroidRunner::logcatProcess(const QByteArray &text, QByteArray &buffer, bool onlyError)
|
||||||
{
|
{
|
||||||
emit remoteErrorOutput(m_adbLogcatProcess.readAllStandardError());
|
QList<QByteArray> lines = text.split('\n');
|
||||||
}
|
|
||||||
|
|
||||||
void AndroidRunner::logcatReadStandardOutput()
|
|
||||||
{
|
|
||||||
if (m_processPID == -1)
|
|
||||||
return;
|
|
||||||
QList<QByteArray> lines = m_adbLogcatProcess.readAllStandardOutput().split('\n');
|
|
||||||
// lines always contains at least one item
|
// lines always contains at least one item
|
||||||
lines[0].prepend(m_logcat);
|
lines[0].prepend(buffer);
|
||||||
if (!lines.last().endsWith('\n')) {
|
if (!lines.last().endsWith('\n')) {
|
||||||
// incomplete line
|
// incomplete line
|
||||||
m_logcat = lines.last();
|
buffer = lines.last();
|
||||||
lines.removeLast();
|
lines.removeLast();
|
||||||
} else {
|
} else {
|
||||||
m_logcat.clear();
|
buffer.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
QByteArray pid(QString::fromLatin1("%1):").arg(m_processPID).toLatin1());
|
QByteArray pid(QString::fromLatin1("%1):").arg(m_processPID).toLatin1());
|
||||||
@@ -378,7 +371,7 @@ void AndroidRunner::logcatReadStandardOutput()
|
|||||||
if (line.endsWith('\r'))
|
if (line.endsWith('\r'))
|
||||||
line.chop(1);
|
line.chop(1);
|
||||||
line.append('\n');
|
line.append('\n');
|
||||||
if (line.startsWith("E/")
|
if (onlyError || line.startsWith("E/")
|
||||||
|| line.startsWith("D/Qt")
|
|| line.startsWith("D/Qt")
|
||||||
|| line.startsWith("W/"))
|
|| line.startsWith("W/"))
|
||||||
emit remoteErrorOutput(line);
|
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)
|
void AndroidRunner::adbKill(qint64 pid)
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -82,6 +82,7 @@ private:
|
|||||||
void forceStop();
|
void forceStop();
|
||||||
QByteArray runPs();
|
QByteArray runPs();
|
||||||
void findPs();
|
void findPs();
|
||||||
|
void logcatProcess(const QByteArray &text, QByteArray &buffer, bool onlyError);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QProcess m_adbLogcatProcess;
|
QProcess m_adbLogcatProcess;
|
||||||
@@ -89,7 +90,8 @@ private:
|
|||||||
bool m_wasStarted;
|
bool m_wasStarted;
|
||||||
int m_tries;
|
int m_tries;
|
||||||
|
|
||||||
QByteArray m_logcat;
|
QByteArray m_stdoutBuffer;
|
||||||
|
QByteArray m_stderrBuffer;
|
||||||
QString m_intentName;
|
QString m_intentName;
|
||||||
QString m_packageName;
|
QString m_packageName;
|
||||||
QString m_deviceSerialNumber;
|
QString m_deviceSerialNumber;
|
||||||
|
|||||||
Reference in New Issue
Block a user