QmlTooling: Retry local client connection on error

So far the local client connection would give up if it could not
connect to the server on the first try. Considering that you cannot
reset the connection, this is very harsh. Instead, retry on failure.

Change-Id: I68464b7b99b94a4b0fb2722d718a43a1c0889f40
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
Ulf Hermann 2016-08-29 16:43:48 +02:00
parent ac868aa088
commit 47c84e6b5e
2 changed files with 13 additions and 10 deletions

View File

@ -43,6 +43,8 @@
#include <QtCore/qplugin.h>
#include <QtNetwork/qlocalsocket.h>
Q_DECLARE_METATYPE(QLocalSocket::LocalSocketError)
QT_BEGIN_NAMESPACE
@ -133,8 +135,14 @@ bool QLocalClientConnection::connectToServer()
{
m_socket = new QLocalSocket;
m_socket->setParent(this);
QObject::connect(m_socket, &QLocalSocket::connected,
this, &QLocalClientConnection::connectionEstablished);
connect(m_socket, &QLocalSocket::connected,
this, &QLocalClientConnection::connectionEstablished);
connect(m_socket, static_cast<void(QLocalSocket::*)(QLocalSocket::LocalSocketError)>(
&QLocalSocket::error), m_socket, [this](QLocalSocket::LocalSocketError) {
m_socket->disconnectFromServer();
m_socket->connectToServer(m_filename);
}, Qt::QueuedConnection);
m_socket->connectToServer(m_filename);
qDebug("QML Debugger: Connecting to socket %s...", m_filename.toLatin1().constData());
return true;

View File

@ -51,12 +51,6 @@ private:
QQmlDebugConnection *m_conn;
QQmlDebugTestService *m_service;
bool connect();
signals:
void waiting();
void parallel();
private slots:
void initTestCase();
@ -75,12 +69,13 @@ void tst_QQmlDebugLocal::initTestCase()
const QString waitingMsg = QString("QML Debugger: Connecting to socket %1...").arg(fileName);
QTest::ignoreMessage(QtDebugMsg, waitingMsg.toLatin1().constData());
QQmlDebuggingEnabler::connectToLocalDebugger(fileName);
QTest::qWait(1000);
m_conn = new QQmlDebugConnection(this);
m_conn->startLocalServer(fileName);
QQmlDebuggingEnabler::connectToLocalDebugger(fileName);
new QQmlEngine(this);
QQmlDebugTestClient client("tst_QQmlDebugLocal::handshake()", m_conn);