Skip to content

Commit

Permalink
Use macro conditional to change to errorOccurred from error
Browse files Browse the repository at this point in the history
Qt 5.15 and above has deprecated QAbstractSocket::error in favor of
QAbstractSocket::errorOccurred
  • Loading branch information
jamescowens committed Aug 19, 2021
1 parent 28d1b46 commit 0d7dca8
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/qt/diagnosticsdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -413,8 +413,14 @@ void DiagnosticsDialog::VerifyClock(unsigned int connections)
m_udpSocket = new QUdpSocket(this);

connect(m_udpSocket, &QUdpSocket::stateChanged, this, &DiagnosticsDialog::clkStateChanged);

// For Qt 5.15 and above QAbstractSocket::error has been deprecated in favor of errorOccurred.
#if (QT_VERSION < QT_VERSION_CHECK(5, 15, 0))
connect(m_udpSocket, static_cast<QAbstractSocket::SocketError (QUdpSocket::*)() const>(&QUdpSocket::error),
this, static_cast<void (DiagnosticsDialog::*)()>(&DiagnosticsDialog::clkSocketError));
#else
connect(m_udpSocket, &QUdpSocket::errorOccurred, this, &DiagnosticsDialog::clkSocketError);
#endif

if (!NTPHost.addresses().empty())
{
Expand Down Expand Up @@ -539,8 +545,15 @@ void DiagnosticsDialog::VerifyTCPPort()
m_tcpSocket = new QTcpSocket(this);

connect(m_tcpSocket, &QTcpSocket::connected, this, &DiagnosticsDialog::TCPFinished);

// For Qt 5.15 and above QAbstractSocket::error has been deprecated in favor of errorOccurred.
#if (QT_VERSION < QT_VERSION_CHECK(5, 15, 0))
connect(m_tcpSocket, static_cast<void (QTcpSocket::*)(QAbstractSocket::SocketError)>(&QTcpSocket::error),
this, static_cast<void (DiagnosticsDialog::*)(QAbstractSocket::SocketError)>(&DiagnosticsDialog::TCPFailed));
#else
connect(m_tcpSocket, static_cast<void (QTcpSocket::*)(QAbstractSocket::SocketError)>(&QTcpSocket::errorOccurred),
this, static_cast<void (DiagnosticsDialog::*)(QAbstractSocket::SocketError)>(&DiagnosticsDialog::TCPFailed));
#endif

m_tcpSocket->connectToHost("portquiz.net", GetListenPort());
}
Expand Down

0 comments on commit 0d7dca8

Please sign in to comment.