Browse Source

TCPLink: Add new errorOccurred for Qt 5.15 builds

Signed-off-by: Patrick José Pereira <patrickelectric@gmail.com>
QGC4.4
Patrick José Pereira 5 years ago
parent
commit
dc20cf6449
  1. 9
      src/comm/TCPLink.cc

9
src/comm/TCPLink.cc

@ -150,12 +150,21 @@ bool TCPLink::_hardwareConnect() @@ -150,12 +150,21 @@ bool TCPLink::_hardwareConnect()
Q_ASSERT(_socket == nullptr);
_socket = new QTcpSocket();
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
QSignalSpy errorSpy(_socket, static_cast<void (QTcpSocket::*)(QAbstractSocket::SocketError)>(&QTcpSocket::error));
#else
QSignalSpy errorSpy(_socket, &QAbstractSocket::errorOccurred);
#endif
_socket->connectToHost(_tcpConfig->address(), _tcpConfig->port());
QObject::connect(_socket, &QTcpSocket::readyRead, this, &TCPLink::readBytes);
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
QObject::connect(_socket,static_cast<void (QTcpSocket::*)(QAbstractSocket::SocketError)>(&QTcpSocket::error),
this, &TCPLink::_socketError);
#else
QObject::connect(_socket, &QAbstractSocket::errorOccurred, this, &TCPLink::_socketError);
#endif
// Give the socket a second to connect to the other side otherwise error out
if (!_socket->waitForConnected(1000))

Loading…
Cancel
Save