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

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

    XMLWordPrintable

Details

    • Windows
    • 25
    • 3f05f97de (dev), 746a2435c (6.9), faf12a1de (6.8), de3697f3e (tqtc/lts-6.5)
    • Foundation Sprint 121

    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

        For Gerrit Dashboard: QTBUG-84689
        # Subject Branch Project Status CR V

        Activity

          People

            ivan.solovev Ivan Solovev
            willhunt will hunt
            Vladimir Minenko Vladimir Minenko
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes