diff --git a/src/plugins/coreplugin/ssh/sshchannel.cpp b/src/plugins/coreplugin/ssh/sshchannel.cpp index 0d809171a3c862b0a6af27123a694ac42b068f57..39c3fffbce1a83c222daa8fb0a6a151aa5306551 100644 --- a/src/plugins/coreplugin/ssh/sshchannel.cpp +++ b/src/plugins/coreplugin/ssh/sshchannel.cpp @@ -234,7 +234,6 @@ void AbstractSshChannel::closeChannel() setChannelState(CloseRequested); m_sendFacility.sendChannelEofPacket(m_remoteChannel); m_sendFacility.sendChannelClosePacket(m_remoteChannel); - m_timeoutTimer->start(ReplyTimeout); } } } diff --git a/src/plugins/coreplugin/ssh/sshconnection.cpp b/src/plugins/coreplugin/ssh/sshconnection.cpp index 1746785a61c5ca051a98fd32b8eebaf87708e799..0a98068a2eeb8e5e95eb9b5f4a523d19a4a9d211 100644 --- a/src/plugins/coreplugin/ssh/sshconnection.cpp +++ b/src/plugins/coreplugin/ssh/sshconnection.cpp @@ -406,6 +406,7 @@ void SshConnectionPrivate::handleUserAuthSuccessPacket() void SshConnectionPrivate::handleUserAuthFailurePacket() { + m_timeoutTimer.stop(); const QString errorMsg = m_connParams.authType == SshConnectionParameters::AuthByPwd ? tr("Server rejected password.") : tr("Server rejected key."); throw SshClientException(SshAuthenticationError, errorMsg); diff --git a/src/plugins/qt4projectmanager/qt-maemo/maemodeploystep.cpp b/src/plugins/qt4projectmanager/qt-maemo/maemodeploystep.cpp index e4080c750cd468c58a05bf1673b9d2ae794bf6e6..43bed218f18e28c5b78a15c0ca2e07b6b773e91d 100644 --- a/src/plugins/qt4projectmanager/qt-maemo/maemodeploystep.cpp +++ b/src/plugins/qt4projectmanager/qt-maemo/maemodeploystep.cpp @@ -195,6 +195,7 @@ const MaemoPackageCreationStep *MaemoDeployStep::packagingStep() const void MaemoDeployStep::raiseError(const QString &errorString) { + disconnect(m_connection.data(), 0, this, 0); emit addTask(Task(Task::Error, errorString, QString(), -1, Constants::TASK_CATEGORY_BUILDSYSTEM)); emit error(); diff --git a/src/plugins/qt4projectmanager/qt-maemo/maemodeploystep.h b/src/plugins/qt4projectmanager/qt-maemo/maemodeploystep.h index 559109cb855a5e5d9474b47ebe6a4fc602ae2876..30a13f4f81a5b7c35dae8903ad5df6e20c775d48 100644 --- a/src/plugins/qt4projectmanager/qt-maemo/maemodeploystep.h +++ b/src/plugins/qt4projectmanager/qt-maemo/maemodeploystep.h @@ -83,6 +83,7 @@ public: const MaemoDeployable &deployable) const; void setDeployed(const QString &host, const MaemoDeployable &deployable); MaemoDeployables *deployables() const { return m_deployables; } + QSharedPointer<Core::SshConnection> sshConnection() const { return m_connection; } signals: void done(); diff --git a/src/plugins/qt4projectmanager/qt-maemo/maemoruncontrol.cpp b/src/plugins/qt4projectmanager/qt-maemo/maemoruncontrol.cpp index 74fbe1d508fafd4f0e092d4713f8320229629be9..7d8d72b44dff910c8b86f9348c3b931def0bc6cc 100644 --- a/src/plugins/qt4projectmanager/qt-maemo/maemoruncontrol.cpp +++ b/src/plugins/qt4projectmanager/qt-maemo/maemoruncontrol.cpp @@ -145,9 +145,9 @@ bool MaemoRunControl::isRunning() const void MaemoRunControl::handleError(const QString &errString) { - QMessageBox::critical(0, tr("Remote Execution Failure"), errString); - emit appendMessage(this, errString, true); stop(); + emit appendMessage(this, errString, true); + QMessageBox::critical(0, tr("Remote Execution Failure"), errString); } void MaemoRunControl::setFinished() diff --git a/src/plugins/qt4projectmanager/qt-maemo/maemosshrunner.cpp b/src/plugins/qt4projectmanager/qt-maemo/maemosshrunner.cpp index 91d361df105bee8c342eb4597e26971cac9d9994..4a9d18e18efc4a4e3e9187ba206e5cb4c3e1e300 100644 --- a/src/plugins/qt4projectmanager/qt-maemo/maemosshrunner.cpp +++ b/src/plugins/qt4projectmanager/qt-maemo/maemosshrunner.cpp @@ -34,6 +34,7 @@ #include "maemosshrunner.h" +#include "maemodeploystep.h" #include "maemodeviceconfigurations.h" #include "maemoglobal.h" #include "maemoremotemounter.h" @@ -89,9 +90,10 @@ void MaemoSshRunner::start() m_exitStatus = -1; if (m_connection) disconnect(m_connection.data(), 0, this, 0); - const bool reUse = m_connection - && m_connection->state() == SshConnection::Connected - && m_connection->connectionParameters() == m_devConfig.server; + bool reUse = isConnectionUsable(); + if (!reUse) + m_connection = m_runConfig->deployStep()->sshConnection(); + reUse = isConnectionUsable(); if (!reUse) m_connection = SshConnection::create(); connect(m_connection.data(), SIGNAL(connected()), this, @@ -112,7 +114,6 @@ void MaemoSshRunner::stop() return; m_stop = true; - disconnect(m_connection.data(), 0, this, 0); m_mounter->stop(); if (m_cleaner) disconnect(m_cleaner.data(), 0, this, 0); @@ -135,6 +136,9 @@ void MaemoSshRunner::handleConnectionFailure() void MaemoSshRunner::cleanup(bool initialCleanup) { + if (!isConnectionUsable()) + return; + emit reportProgress(tr("Killing remote process(es)...")); m_shuttingDown = !initialCleanup; QString niceKill; @@ -159,6 +163,7 @@ void MaemoSshRunner::handleCleanupFinished(int exitStatus) || exitStatus == SshRemoteProcess::ExitedNormally); if (m_shuttingDown) { + m_unmountState = ShutdownUnmount; m_mounter->unmount(); return; } @@ -171,13 +176,44 @@ void MaemoSshRunner::handleCleanupFinished(int exitStatus) .arg(m_cleaner->errorString())); } else { m_mounter->setConnection(m_connection); + m_unmountState = InitialUnmount; m_mounter->unmount(); } } void MaemoSshRunner::handleUnmounted() { - if (m_shuttingDown) { + switch (m_unmountState) { + case InitialUnmount: { + if (m_stop) + return; + MaemoPortList portList = m_devConfig.freePorts(); + if (m_debugging && !m_runConfig->useRemoteGdb()) + portList.getNext(); // One has already been used for gdbserver. + m_mounter->setPortList(portList); + const MaemoRemoteMountsModel * const remoteMounts + = m_runConfig->remoteMounts(); + for (int i = 0; i < remoteMounts->mountSpecificationCount(); ++i) { + if (!addMountSpecification(remoteMounts->mountSpecificationAt(i))) + return; + } + if (m_debugging && m_runConfig->useRemoteGdb()) { + if (!addMountSpecification(MaemoMountSpecification( + m_runConfig->localDirToMountForRemoteGdb(), + MaemoGlobal::remoteProjectSourcesMountPoint()))) + return; + } + m_unmountState = PreMountUnmount; + m_mounter->unmount(); + break; + } + case PreMountUnmount: + if (m_stop) + return; + m_mounter->mount(); + break; + case ShutdownUnmount: + Q_ASSERT(m_shuttingDown); m_shuttingDown = false; if (m_exitStatus == SshRemoteProcess::ExitedNormally) { emit remoteProcessFinished(m_runner->exitCode()); @@ -188,29 +224,8 @@ void MaemoSshRunner::handleUnmounted() .arg(m_runner->errorString())); } m_exitStatus = -1; - return; + break; } - - if (m_stop) - return; - - MaemoPortList portList = m_devConfig.freePorts(); - if (m_debugging && !m_runConfig->useRemoteGdb()) - portList.getNext(); // One has already been used for gdbserver. - m_mounter->setPortList(portList); - const MaemoRemoteMountsModel * const remoteMounts - = m_runConfig->remoteMounts(); - for (int i = 0; i < remoteMounts->mountSpecificationCount(); ++i) { - if (!addMountSpecification(remoteMounts->mountSpecificationAt(i))) - return; - } - if (m_debugging && m_runConfig->useRemoteGdb()) { - if (!addMountSpecification(MaemoMountSpecification( - m_runConfig->localDirToMountForRemoteGdb(), - MaemoGlobal::remoteProjectSourcesMountPoint()))) - return; - } - m_mounter->mount(); } void MaemoSshRunner::handleMounted() @@ -265,6 +280,12 @@ bool MaemoSshRunner::addMountSpecification(const MaemoMountSpecification &mountS return true; } +bool MaemoSshRunner::isConnectionUsable() const +{ + return m_connection && m_connection->state() == SshConnection::Connected + && m_connection->connectionParameters() == m_devConfig.server; +} + } // namespace Internal } // namespace Qt4ProjectManager diff --git a/src/plugins/qt4projectmanager/qt-maemo/maemosshrunner.h b/src/plugins/qt4projectmanager/qt-maemo/maemosshrunner.h index e84a1cb01428f8b1a0691d1d2c39cd6e5a49161c..de079d8c27315b136b2706a1e99e303a81cd4a52 100644 --- a/src/plugins/qt4projectmanager/qt-maemo/maemosshrunner.h +++ b/src/plugins/qt4projectmanager/qt-maemo/maemosshrunner.h @@ -90,6 +90,7 @@ private slots: private: void cleanup(bool initialCleanup); bool addMountSpecification(const MaemoMountSpecification &mountSpec); + bool isConnectionUsable() const; MaemoRunConfiguration * const m_runConfig; // TODO this pointer can be invalid MaemoRemoteMounter * const m_mounter; @@ -104,6 +105,9 @@ private: int m_exitStatus; bool m_shuttingDown; const bool m_debugging; + + enum UnmountState { InitialUnmount, PreMountUnmount, ShutdownUnmount }; + UnmountState m_unmountState; }; } // namespace Internal