From: Christian Kandeler Date: Tue, 5 Jul 2011 16:01:58 +0000 (+0200) Subject: SSH: Don't allow connectToHost() while already connecting/connected. X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=ee635dcf9e865c7bc405b81b09f0df5245c4b32a;p=qt-creator-jp%2Fqt-creator-jp.git SSH: Don't allow connectToHost() while already connecting/connected. Also fix callers potentially violating this policy. Change-Id: I630f1c544885df93a81e217e792363c0c2314108 Reviewed-on: http://codereview.qt.nokia.com/1186 Reviewed-by: Qt Sanity Bot Reviewed-by: Daniel Teske --- diff --git a/src/libs/utils/ssh/sshconnection.cpp b/src/libs/utils/ssh/sshconnection.cpp index 6a712817ed..0efdd0091e 100644 --- a/src/libs/utils/ssh/sshconnection.cpp +++ b/src/libs/utils/ssh/sshconnection.cpp @@ -620,6 +620,8 @@ void SshConnectionPrivate::sendKeepAlivePacket() void SshConnectionPrivate::connectToHost() { + QTC_ASSERT(m_state == SocketUnconnected, return); + m_incomingData.clear(); m_incomingPacket.reset(); m_sendFacility.reset(); diff --git a/src/libs/utils/ssh/sshremoteprocessrunner.cpp b/src/libs/utils/ssh/sshremoteprocessrunner.cpp index 0d5fa24e93..6a751cc37e 100644 --- a/src/libs/utils/ssh/sshremoteprocessrunner.cpp +++ b/src/libs/utils/ssh/sshremoteprocessrunner.cpp @@ -145,7 +145,8 @@ void SshRemoteProcessRunnerPrivate::run(const QByteArray &command) } else { connect(m_connection.data(), SIGNAL(connected()), SLOT(handleConnected())); - m_connection->connectToHost(); + if (m_connection->state() == SshConnection::Unconnected) + m_connection->connectToHost(); } } diff --git a/src/plugins/debugger/gdb/remotegdbprocess.cpp b/src/plugins/debugger/gdb/remotegdbprocess.cpp index f32af660e0..124e43f620 100644 --- a/src/plugins/debugger/gdb/remotegdbprocess.cpp +++ b/src/plugins/debugger/gdb/remotegdbprocess.cpp @@ -98,7 +98,8 @@ void RemoteGdbProcess::realStart(const QString &cmd, const QStringList &args, handleConnected(); } else { connect(m_conn.data(), SIGNAL(connected()), this, SLOT(handleConnected())); - m_conn->connectToHost(); + if (m_conn->state() == SshConnection::Unconnected) + m_conn->connectToHost(); } } diff --git a/src/plugins/remotelinux/abstractmaemodeploystep.cpp b/src/plugins/remotelinux/abstractmaemodeploystep.cpp index e305bdc719..3275550245 100644 --- a/src/plugins/remotelinux/abstractmaemodeploystep.cpp +++ b/src/plugins/remotelinux/abstractmaemodeploystep.cpp @@ -298,7 +298,8 @@ void AbstractMaemoDeployStep::connectToDevice() connect(m_connection.data(), SIGNAL(connected()), this, SLOT(handleConnected())); writeOutput(tr("Connecting to device...")); - m_connection->connectToHost(); + if (m_connection->state() == SshConnection::Unconnected) + m_connection->connectToHost(); } } diff --git a/src/plugins/remotelinux/remotelinuxapplicationrunner.cpp b/src/plugins/remotelinux/remotelinuxapplicationrunner.cpp index 57ecf01e0a..340f4154bb 100644 --- a/src/plugins/remotelinux/remotelinuxapplicationrunner.cpp +++ b/src/plugins/remotelinux/remotelinuxapplicationrunner.cpp @@ -105,7 +105,8 @@ void RemoteLinuxApplicationRunner::start() handleConnected(); } else { emit reportProgress(tr("Connecting to device...")); - m_connection->connectToHost(); + if (m_connection->state() == Utils::SshConnection::Unconnected) + m_connection->connectToHost(); } } diff --git a/src/plugins/valgrind/valgrind/valgrindprocess.cpp b/src/plugins/valgrind/valgrind/valgrindprocess.cpp index 2be53c433a..b2da5551f2 100644 --- a/src/plugins/valgrind/valgrind/valgrindprocess.cpp +++ b/src/plugins/valgrind/valgrind/valgrindprocess.cpp @@ -186,7 +186,8 @@ void RemoteValgrindProcess::run(const QString &valgrindExecutable, const QString this, SLOT(connected())); connect(m_connection.data(), SIGNAL(error(Utils::SshError)), this, SLOT(error(Utils::SshError))); - m_connection->connectToHost(); + if (m_connection->state() == Utils::SshConnection::Unconnected) + m_connection->connectToHost(); } else { connected(); }