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));
|
||||
});
|
||||
|
||||
connect(socket, QOverload<QAbstractSocket::SocketError>::of(&QAbstractSocket::error),
|
||||
this, [this](QAbstractSocket::SocketError error) {
|
||||
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
|
||||
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));
|
||||
socketDisconnected();
|
||||
}, Qt::QueuedConnection);
|
||||
|
||||
@@ -288,8 +288,12 @@ bool DesignerExternalEditor::startEditor(const QString &fileName, QString *error
|
||||
m_processCache.insert(binary, socket);
|
||||
auto mapSlot = [this, binary] { processTerminated(binary); };
|
||||
connect(socket, &QAbstractSocket::disconnected, this, mapSlot);
|
||||
connect(socket, QOverload<QAbstractSocket::SocketError>::of(&QAbstractSocket::error),
|
||||
this, mapSlot);
|
||||
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
|
||||
const auto errorOccurred = QOverload<QAbstractSocket::SocketError>::of(&QAbstractSocket::error);
|
||||
#else
|
||||
const auto errorOccurred = &QAbstractSocket::errorOccurred;
|
||||
#endif
|
||||
connect(socket, errorOccurred, this, mapSlot);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -225,9 +225,12 @@ void Relayer::setClientSocket(QTcpSocket *clientSocket)
|
||||
QTC_CHECK(!m_clientSocket);
|
||||
m_clientSocket = clientSocket;
|
||||
if (m_clientSocket) {
|
||||
connect(m_clientSocket,
|
||||
QOverload<QAbstractSocket::SocketError>::of(&QAbstractSocket::error),
|
||||
this, &Relayer::handleClientHasError);
|
||||
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
|
||||
const auto errorOccurred = QOverload<QAbstractSocket::SocketError>::of(&QAbstractSocket::error);
|
||||
#else
|
||||
const auto errorOccurred = &QAbstractSocket::errorOccurred;
|
||||
#endif
|
||||
connect(m_clientSocket, errorOccurred, this, &Relayer::handleClientHasError);
|
||||
connect(m_clientSocket, &QAbstractSocket::disconnected,
|
||||
this, [this](){server()->removeRelayConnection(this);});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user