forked from qt-creator/qt-creator
Handle various versions for QAbstractSocket::SocketError{Occurred}
I don't think it's worthwhile to put that in some header, it's only four occurrences. Task-number: QTCREATORBUG-24098 Change-Id: Ic4e505f264a5d9970d8be1071c849d2bb3389746 Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
@@ -346,8 +346,12 @@ void QmlDebugConnection::connectToHost(const QString &hostName, quint16 port)
|
|||||||
emit logStateChange(socketStateToString(state));
|
emit logStateChange(socketStateToString(state));
|
||||||
});
|
});
|
||||||
|
|
||||||
connect(socket, QOverload<QAbstractSocket::SocketError>::of(&QAbstractSocket::error),
|
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
|
||||||
this, [this](QAbstractSocket::SocketError error) {
|
const auto errorOccurred = QOverload<QAbstractSocket::SocketError>::of(&QAbstractSocket::error);
|
||||||
|
#else
|
||||||
|
const auto errorOccurred = &QAbstractSocket::errorOccurred;
|
||||||
|
#endif
|
||||||
|
connect(socket, errorOccurred, this, [this](QAbstractSocket::SocketError error) {
|
||||||
emit logError(socketErrorToString(error));
|
emit logError(socketErrorToString(error));
|
||||||
socketDisconnected();
|
socketDisconnected();
|
||||||
}, Qt::QueuedConnection);
|
}, Qt::QueuedConnection);
|
||||||
|
|||||||
@@ -288,8 +288,12 @@ bool DesignerExternalEditor::startEditor(const QString &fileName, QString *error
|
|||||||
m_processCache.insert(binary, socket);
|
m_processCache.insert(binary, socket);
|
||||||
auto mapSlot = [this, binary] { processTerminated(binary); };
|
auto mapSlot = [this, binary] { processTerminated(binary); };
|
||||||
connect(socket, &QAbstractSocket::disconnected, this, mapSlot);
|
connect(socket, &QAbstractSocket::disconnected, this, mapSlot);
|
||||||
connect(socket, QOverload<QAbstractSocket::SocketError>::of(&QAbstractSocket::error),
|
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
|
||||||
this, mapSlot);
|
const auto errorOccurred = QOverload<QAbstractSocket::SocketError>::of(&QAbstractSocket::error);
|
||||||
|
#else
|
||||||
|
const auto errorOccurred = &QAbstractSocket::errorOccurred;
|
||||||
|
#endif
|
||||||
|
connect(socket, errorOccurred, this, mapSlot);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -225,9 +225,12 @@ void Relayer::setClientSocket(QTcpSocket *clientSocket)
|
|||||||
QTC_CHECK(!m_clientSocket);
|
QTC_CHECK(!m_clientSocket);
|
||||||
m_clientSocket = clientSocket;
|
m_clientSocket = clientSocket;
|
||||||
if (m_clientSocket) {
|
if (m_clientSocket) {
|
||||||
connect(m_clientSocket,
|
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
|
||||||
QOverload<QAbstractSocket::SocketError>::of(&QAbstractSocket::error),
|
const auto errorOccurred = QOverload<QAbstractSocket::SocketError>::of(&QAbstractSocket::error);
|
||||||
this, &Relayer::handleClientHasError);
|
#else
|
||||||
|
const auto errorOccurred = &QAbstractSocket::errorOccurred;
|
||||||
|
#endif
|
||||||
|
connect(m_clientSocket, errorOccurred, this, &Relayer::handleClientHasError);
|
||||||
connect(m_clientSocket, &QAbstractSocket::disconnected,
|
connect(m_clientSocket, &QAbstractSocket::disconnected,
|
||||||
this, [this](){server()->removeRelayConnection(this);});
|
this, [this](){server()->removeRelayConnection(this);});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user