forked from qt-creator/qt-creator
QmlProfiler: Deobfuscate connection mechanism
Whenever we create the connection we as well try connectToHost() immediately instead of deferring it until the next timeout. The else branch in tryToConnect() would never be executed because if the connection is there and not connecting or connected, then the socketState must be != ConnectedState. Change-Id: I6736b35348671961fbb3a48edb5e9c6c1d7ce915 Reviewed-by: Joerg Bornemann <joerg.bornemann@theqtcompany.com>
This commit is contained in:
@@ -152,6 +152,7 @@ void QmlProfilerClientManager::connectTcpClient(quint16 port)
|
|||||||
createConnection();
|
createConnection();
|
||||||
d->connectionTimer.start();
|
d->connectionTimer.start();
|
||||||
d->tcpPort = port;
|
d->tcpPort = port;
|
||||||
|
d->connection->connectToHost(d->tcpHost, d->tcpPort);
|
||||||
}
|
}
|
||||||
|
|
||||||
void QmlProfilerClientManager::connectLocalClient(const QString &file)
|
void QmlProfilerClientManager::connectLocalClient(const QString &file)
|
||||||
@@ -240,14 +241,6 @@ void QmlProfilerClientManager::disconnectClientSignals()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void QmlProfilerClientManager::connectToClient()
|
|
||||||
{
|
|
||||||
if (!d->connection || d->connection->isConnected() || d->connection->isConnecting())
|
|
||||||
return;
|
|
||||||
|
|
||||||
d->connection->connectToHost(d->tcpHost, d->tcpPort);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool QmlProfilerClientManager::isConnected() const
|
bool QmlProfilerClientManager::isConnected() const
|
||||||
{
|
{
|
||||||
return d->connection && d->connection->isConnected();
|
return d->connection && d->connection->isConnected();
|
||||||
@@ -270,8 +263,7 @@ void QmlProfilerClientManager::tryToConnect()
|
|||||||
if (d->connection && d->connection->isConnected()) {
|
if (d->connection && d->connection->isConnected()) {
|
||||||
d->connectionTimer.stop();
|
d->connectionTimer.stop();
|
||||||
d->connectionAttempts = 0;
|
d->connectionAttempts = 0;
|
||||||
} else if (d->connection &&
|
} else if (d->connection && d->connection->socketState() != QAbstractSocket::ConnectedState) {
|
||||||
d->connection->socketState() != QAbstractSocket::ConnectedState) {
|
|
||||||
// Replace the connection after trying for some time. On some operating systems (OSX) the
|
// Replace the connection after trying for some time. On some operating systems (OSX) the
|
||||||
// very first connection to a TCP server takes a very long time to get established.
|
// very first connection to a TCP server takes a very long time to get established.
|
||||||
|
|
||||||
@@ -280,7 +272,6 @@ void QmlProfilerClientManager::tryToConnect()
|
|||||||
delete d->connection;
|
delete d->connection;
|
||||||
d->connection = 0;
|
d->connection = 0;
|
||||||
connectTcpClient(d->tcpPort);
|
connectTcpClient(d->tcpPort);
|
||||||
connectToClient();
|
|
||||||
} else if (d->connectionAttempts == 50) {
|
} else if (d->connectionAttempts == 50) {
|
||||||
d->connectionTimer.stop();
|
d->connectionTimer.stop();
|
||||||
d->connectionAttempts = 0;
|
d->connectionAttempts = 0;
|
||||||
@@ -302,8 +293,6 @@ void QmlProfilerClientManager::tryToConnect()
|
|||||||
this, &QmlProfilerClientManager::retryMessageBoxFinished);
|
this, &QmlProfilerClientManager::retryMessageBoxFinished);
|
||||||
|
|
||||||
infoBox->show();
|
infoBox->show();
|
||||||
} else {
|
|
||||||
connectToClient();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -93,8 +93,6 @@ private:
|
|||||||
class QmlProfilerClientManagerPrivate;
|
class QmlProfilerClientManagerPrivate;
|
||||||
QmlProfilerClientManagerPrivate *d;
|
QmlProfilerClientManagerPrivate *d;
|
||||||
|
|
||||||
void connectToClient();
|
|
||||||
|
|
||||||
void createConnection();
|
void createConnection();
|
||||||
void connectClientSignals();
|
void connectClientSignals();
|
||||||
void disconnectClientSignals();
|
void disconnectClientSignals();
|
||||||
|
Reference in New Issue
Block a user