From 54ecf82208986b9c75a1d77b7a49fa1b67de77f9 Mon Sep 17 00:00:00 2001 From: "qt-info@nokia.com" <qt-info@nokia.com> Date: Thu, 12 Aug 2010 18:06:58 +0200 Subject: [PATCH] Maemo: Cache SSH connection in deployment step. --- .../qt-maemo/maemodeploystep.cpp | 22 +++++++++++++------ 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/src/plugins/qt4projectmanager/qt-maemo/maemodeploystep.cpp b/src/plugins/qt4projectmanager/qt-maemo/maemodeploystep.cpp index 3f6b1b85a06..28cb880d8f2 100644 --- a/src/plugins/qt4projectmanager/qt-maemo/maemodeploystep.cpp +++ b/src/plugins/qt4projectmanager/qt-maemo/maemodeploystep.cpp @@ -301,22 +301,30 @@ void MaemoDeployStep::start() #endif m_stopped = false; - // TODO: Re-use if possible (disconnect + reconnect). - if (m_connection) - disconnect(m_connection.data(), 0, this, 0); - m_connection = SshConnection::create(); - const MaemoDeviceConfig &devConfig = deviceConfig(); if (!devConfig.isValid()) { raiseError(tr("Deployment failed: No valid device set.")); return; } + + if (m_connection) + disconnect(m_connection.data(), 0, this, 0); + const bool canReUse = m_connection + && m_connection->state() == SshConnection::Connected + && m_connection->connectionParameters() == devConfig.server; + if (!canReUse) + m_connection = SshConnection::create(); connect(m_connection.data(), SIGNAL(connected()), this, SLOT(handleConnected())); connect(m_connection.data(), SIGNAL(error(SshError)), this, SLOT(handleConnectionFailure())); - m_connection->connectToHost(devConfig.server); - m_connecting = true; + if (canReUse) { + handleConnected(); + } else { + writeOutput(tr("Connecting to device...")); + m_connecting = true; + m_connection->connectToHost(devConfig.server); + } } void MaemoDeployStep::handleConnected() -- GitLab