Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-66648

QModbusTcpClient never close on disconnect

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P3: Somewhat important
    • Resolution: Done
    • Affects Version/s: 5.10.1
    • Fix Version/s: 5.11.0
    • Component/s: SerialBus: MOD Bus
    • Labels:
      None

      Description

      If you call the disconnectDevice() method on a QModbusTcpClient object that was not opened or has already been closed, then we would never close and would always be in QModbusDevice::ClosingState.

      Status QModbusDevice::ClosingState change to QModbusDevice:: UnconnectedState only when the disconnected signal comes from the internal TcpSocket (see qmodbustcpclient_p.h), but when the socket was not open or has already been closed, signal disconnected is not emitted!

      Source code to illustrate:

      qmodbusdevice.cpp

      void QModbusDevice::disconnectDevice()
      {
          setState(QModbusDevice::ClosingState);
      
          //Unconnected is set by backend -> might be delayed by event loop
          close();
      }
      

      qmodbustcpclient.cpp

      void QModbusTcpClient::close()
      {
          if (state() == QModbusDevice::UnconnectedState)
              return;
      
          Q_D(QModbusTcpClient);
          d->m_socket->disconnectFromHost();
      }
      

      I think we should add an additional check to the method void QModbusTcpClient::close() for reset ClosingState to UnconnectedState

        Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

            Assignee:
            ablasche Alex Blasche
            Reporter:
            koynovstas Stas Koynov
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:

                Gerrit Reviews

                There are no open Gerrit changes