diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2019-06-29 11:02:51 +0200 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@qt.io> | 2019-07-03 12:26:24 +0000 |
commit | 5daae2cf6cf4c2fc1569ed3c5c2f25294ac1a57d (patch) | |
tree | 2b6da5ebb58c05b8d15fef1329fede18f89b0464 /src/libs/qmldebug | |
parent | 7cd504511cc89ea8addbbf5f8295ba7505ea0df4 (diff) |
QmlDebug: Queue the socket error and disconnect signals
Apparently these can be sent synchronously on trying to send something
over the wire. Synchronously handling the signals at that point is
dangerous as the rest of the system might be in some transitional state
(e.g. just destroying the clients).
Fixes: QTCREATORBUG-22640
Change-Id: I21a0c92a6334d401390cf6d92b9b855b83cc6307
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Diffstat (limited to 'src/libs/qmldebug')
-rw-r--r-- | src/libs/qmldebug/qmldebugconnection.cpp | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/src/libs/qmldebug/qmldebugconnection.cpp b/src/libs/qmldebug/qmldebugconnection.cpp index 143277b379..629360a8bc 100644 --- a/src/libs/qmldebug/qmldebugconnection.cpp +++ b/src/libs/qmldebug/qmldebugconnection.cpp @@ -35,6 +35,8 @@ #include <QTcpServer> #include <QTcpSocket> +Q_DECLARE_METATYPE(QLocalSocket::LocalSocketError) + namespace QmlDebug { const int protocolVersion = 1; @@ -244,6 +246,11 @@ void QmlDebugConnection::protocolReadyRead() QmlDebugConnection::QmlDebugConnection(QObject *parent) : QObject(parent), d_ptr(new QmlDebugConnectionPrivate) { + static const int metaTypes[] = { + qRegisterMetaType<QAbstractSocket::SocketError>(), + qRegisterMetaType<QLocalSocket::LocalSocketError>() + }; + Q_UNUSED(metaTypes); } QmlDebugConnection::~QmlDebugConnection() @@ -343,9 +350,10 @@ void QmlDebugConnection::connectToHost(const QString &hostName, quint16 port) this, [this](QAbstractSocket::SocketError error) { emit logError(socketErrorToString(error)); socketDisconnected(); - }); + }, Qt::QueuedConnection); connect(socket, &QAbstractSocket::connected, this, &QmlDebugConnection::socketConnected); - connect(socket, &QAbstractSocket::disconnected, this, &QmlDebugConnection::socketDisconnected); + connect(socket, &QAbstractSocket::disconnected, this, &QmlDebugConnection::socketDisconnected, + Qt::QueuedConnection); socket->connectToHost(hostName.isEmpty() ? QString("localhost") : hostName, port); } @@ -376,13 +384,14 @@ void QmlDebugConnection::newConnection() QObject::connect(d->protocol, &QPacketProtocol::readyRead, this, &QmlDebugConnection::protocolReadyRead); - connect(socket, &QLocalSocket::disconnected, this, &QmlDebugConnection::socketDisconnected); + connect(socket, &QLocalSocket::disconnected, this, &QmlDebugConnection::socketDisconnected, + Qt::QueuedConnection); connect(socket, QOverload<QLocalSocket::LocalSocketError>::of(&QLocalSocket::error), this, [this](QLocalSocket::LocalSocketError error) { emit logError(socketErrorToString(static_cast<QAbstractSocket::SocketError>(error))); socketDisconnected(); - }); + }, Qt::QueuedConnection); connect(socket, &QLocalSocket::stateChanged, this, [this](QLocalSocket::LocalSocketState state) { |