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

readyRead() signal will be reemitted even I have called waitForReadyRead()

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P3: Somewhat important
    • None
    • 5.12.8
    • Serial Port
    • None
    • Windows

    Description

      serial = new QSerialPort(this);
      connect(serial, &QIODevice::readyRead, this, &Dialog::readResponse);
      
      void Dialog::readResponse()
      {
          qDebug() << "ready";
          QByteArray response = serial->readAll();
          while (serial->waitForReadyRead(1000)) {
              response += serial->readAll();
          }
          qDebug() << "done";
      }
      

      The document say that:

      readyRead() is not emitted recursively; if you reenter the event loop or call waitForReadyRead() inside a slot connected to the readyRead() signal, the signal will not be reemitted  

      my understanding is `readResonpse` will only be called once when there were data can be read from serial port until `readResponse` returned, but from my observation,  the "ready" message were printed multiple times, even the "done" message has never been printed

      Attachments

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

        Activity

          People

            Unassigned Unassigned
            willhunt will hunt
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes