summaryrefslogtreecommitdiffstats
path: root/src/libs/installer/remoteclient.cpp
diff options
context:
space:
mode:
authorkh1 <karsten.heimrich@digia.com>2014-06-03 15:35:37 +0200
committerKarsten Heimrich <karsten.heimrich@digia.com>2014-06-03 15:48:08 +0200
commite07968ebb99b7fe4e67c0470ec486a92816036d5 (patch)
treead7e3bf5d95cae2ca57de0b745060f7276c72259 /src/libs/installer/remoteclient.cpp
parent22fb61b60c0686795f9671789ab3393da6c22987 (diff)
We need to pass the socket to the connect function.
The keep alive thread does try to delete the socket it gets from the connect method, but since the socket was created in a different thread and we will hit the: "Socket notifiers cannot be disabled from another thread" warning. Change-Id: Ibafcd67f8cdb51b365c3ef230f1ebd447bdd306a Reviewed-by: Niels Weber <niels.weber@digia.com>
Diffstat (limited to 'src/libs/installer/remoteclient.cpp')
-rw-r--r--src/libs/installer/remoteclient.cpp13
1 files changed, 6 insertions, 7 deletions
diff --git a/src/libs/installer/remoteclient.cpp b/src/libs/installer/remoteclient.cpp
index 60ccb3409..fed7ecc6c 100644
--- a/src/libs/installer/remoteclient.cpp
+++ b/src/libs/installer/remoteclient.cpp
@@ -88,14 +88,13 @@ void RemoteClient::init(quint16 port, const QHostAddress &address, Mode mode)
d->init(port, address, mode);
}
-QTcpSocket *RemoteClient::connect() const
+bool RemoteClient::connect(QTcpSocket *socket) const
{
Q_D(const RemoteClient);
if (d->m_quit)
- return 0;
+ return false;
int tries = 3;
- QScopedPointer<QTcpSocket> socket(new QTcpSocket);
while ((tries > 0) && (!d->m_quit)) {
socket->connectToHost(d->m_address, d->m_port);
@@ -108,10 +107,10 @@ QTcpSocket *RemoteClient::connect() const
continue;
}
if ((socket->state() != QAbstractSocket::ConnectedState) || d->m_quit)
- return 0;
+ return false;
QDataStream stream;
- stream.setDevice(socket.data());
+ stream.setDevice(socket);
stream << QString::fromLatin1(Protocol::Authorize) << d->m_key;
socket->waitForBytesWritten(-1);
@@ -121,9 +120,9 @@ QTcpSocket *RemoteClient::connect() const
quint32 size; stream >> size;
bool authorized; stream >> authorized;
if (authorized && (!d->m_quit))
- return socket.take();
+ return true;
}
- return 0;
+ return false;
}
bool RemoteClient::isActive() const