diff --git a/src/plugins/qt4projectmanager/qt-maemo/maemosshthread.cpp b/src/plugins/qt4projectmanager/qt-maemo/maemosshthread.cpp
index 4b3ee3beb9c132cef7ea94bbdbd30dfddcf8b449..77777bceee998fb660f28cce2f2c3211e7c35b45 100644
--- a/src/plugins/qt4projectmanager/qt-maemo/maemosshthread.cpp
+++ b/src/plugins/qt4projectmanager/qt-maemo/maemosshthread.cpp
@@ -104,8 +104,7 @@ bool MaemoSshRunner::runInternal()
     createConnection();
     connect(m_connection.data(), SIGNAL(remoteOutput(QByteArray)),
             this, SLOT(handleRemoteOutput(QByteArray)));
-    m_endMarkerCount = 0;
-    m_promptEncountered = false;
+    initState();
     if (!m_connection->start())
         return false;
     if (stopRequested())
@@ -115,6 +114,13 @@ bool MaemoSshRunner::runInternal()
     return !m_connection->hasError();
 }
 
+void MaemoSshRunner::initState()
+{
+    m_endMarkerCount = 0;
+    m_promptEncountered = false;
+    m_potentialEndMarkerPrefix.clear();
+}
+
 void MaemoSshRunner::handleRemoteOutput(const QByteArray &curOutput)
 {
     const QByteArray output = m_potentialEndMarkerPrefix + curOutput;
diff --git a/src/plugins/qt4projectmanager/qt-maemo/maemosshthread.h b/src/plugins/qt4projectmanager/qt-maemo/maemosshthread.h
index a01e1bd7c36ecd7aa5cc787297f3b1ad343d6ee7..788bc0582118b01fb3ea3181a987f300f7e0aa25 100644
--- a/src/plugins/qt4projectmanager/qt-maemo/maemosshthread.h
+++ b/src/plugins/qt4projectmanager/qt-maemo/maemosshthread.h
@@ -97,6 +97,7 @@ signals:
 private:
     virtual bool runInternal();
     Q_SLOT void handleRemoteOutput(const QByteArray &output);
+    void initState();
 
     static const QByteArray EndMarker;