* @brief Handles socket errors by disconnecting and showing a message box. */
| 527 | * @brief Handles socket errors by disconnecting and showing a message box. |
| 528 | */ |
| 529 | void IO::Drivers::Network::onErrorOccurred(const QAbstractSocket::SocketError socketError) |
| 530 | { |
| 531 | if (m_connecting) |
| 532 | return; |
| 533 | |
| 534 | if (socketType() == QAbstractSocket::UdpSocket |
| 535 | && socketError == QAbstractSocket::ConnectionRefusedError) [[unlikely]] |
| 536 | return; |
| 537 | |
| 538 | QString error; |
| 539 | if (socketType() == QAbstractSocket::TcpSocket) |
| 540 | error = m_tcpSocket.errorString(); |
| 541 | else if (socketType() == QAbstractSocket::UdpSocket) |
| 542 | error = m_udpSocket.errorString(); |
| 543 | else |
| 544 | error = QString::number(socketError); |
| 545 | |
| 546 | ConnectionManager::instance().disconnectDevice(this); |
| 547 | Misc::Utilities::showMessageBox(tr("Network socket error"), error, QMessageBox::Critical); |
| 548 | } |
| 549 | |
| 550 | //-------------------------------------------------------------------------------------------------- |
| 551 | // Driver property model |
nothing calls this directly
no test coverage detected