From 47c84e6b5e1162a6143663723e6b948b01d44c17 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Mon, 29 Aug 2016 16:43:48 +0200 Subject: 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 --- .../qmltooling/qmldbg_local/qlocalclientconnection.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/qmltooling/qmldbg_local/qlocalclientconnection.cpp b/src/plugins/qmltooling/qmldbg_local/qlocalclientconnection.cpp index 64b26bdd0d..6152853917 100644 --- a/src/plugins/qmltooling/qmldbg_local/qlocalclientconnection.cpp +++ b/src/plugins/qmltooling/qmldbg_local/qlocalclientconnection.cpp @@ -43,6 +43,8 @@ #include #include +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( + &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; -- cgit v1.2.3