From 64d65fb69811da29fa29b9e08ddd3b8a58e4cee3 Mon Sep 17 00:00:00 2001 From: ck <qt-info@nokia.com> Date: Wed, 12 May 2010 16:45:23 +0200 Subject: [PATCH] Maemo: Fix corner case in end-of-remote-process detection. --- .../qt4projectmanager/qt-maemo/maemosshthread.cpp | 12 +++++++----- .../qt4projectmanager/qt-maemo/maemosshthread.h | 1 + 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/plugins/qt4projectmanager/qt-maemo/maemosshthread.cpp b/src/plugins/qt4projectmanager/qt-maemo/maemosshthread.cpp index f156f6a0868..081f7eb7ff8 100644 --- a/src/plugins/qt4projectmanager/qt-maemo/maemosshthread.cpp +++ b/src/plugins/qt4projectmanager/qt-maemo/maemosshthread.cpp @@ -117,7 +117,8 @@ bool MaemoSshRunner::runInternal() void MaemoSshRunner::handleRemoteOutput() { - const QByteArray output = m_connection->waitForRemoteOutput(0); + const QByteArray output + = m_potentialEndMarkerPrefix + m_connection->waitForRemoteOutput(0); // Wait for a prompt before sending the command. if (!m_promptEncountered) { @@ -143,8 +144,6 @@ void MaemoSshRunner::handleRemoteOutput() /* * The output the user should see is everything after the first * and before the last occurrence of our marker string. - * Note: We don't currently handle the case of an incomplete unicode - * character being sent. */ int firstCharToEmit; int charsToEmitCount; @@ -168,16 +167,19 @@ void MaemoSshRunner::handleRemoteOutput() if (m_endMarkerCount == 0) { charsToEmitCount = 0; } else { - firstCharToEmit = 0; + firstCharToEmit = m_potentialEndMarkerPrefix.count(); charsToEmitCount = -1; } } - if (charsToEmitCount != 0) + if (charsToEmitCount != 0) { emit remoteOutput(QString::fromUtf8(output.data() + firstCharToEmit, charsToEmitCount)); + } if (m_endMarkerCount == 2) stop(); + + m_potentialEndMarkerPrefix = output.right(EndMarker.count() - 1); } const QByteArray MaemoSshRunner::EndMarker(QString(QChar(0x13a0)).toUtf8()); diff --git a/src/plugins/qt4projectmanager/qt-maemo/maemosshthread.h b/src/plugins/qt4projectmanager/qt-maemo/maemosshthread.h index 112f2c4bb15..ee17d4b104b 100644 --- a/src/plugins/qt4projectmanager/qt-maemo/maemosshthread.h +++ b/src/plugins/qt4projectmanager/qt-maemo/maemosshthread.h @@ -104,6 +104,7 @@ private: const char *m_prompt; int m_endMarkerCount; bool m_promptEncountered; + QByteArray m_potentialEndMarkerPrefix; }; -- GitLab