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

QIODevice::readAll() may call long loop on sequetial IO devices

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Incomplete
    • Icon: Not Evaluated Not Evaluated
    • None
    • 5.4.0
    • Core: I/O
    • None

      When reimplementing QIODevice for sequential devices with highly loaded output stream, method readAll() may call long loop in code:

          if (d->isSequential() || (theSize = size()) == 0) {
              // Size is unknown, read incrementally.
              qint64 readResult;
              do {
                  result.resize(result.size() + QIODEVICE_BUFFERSIZE);
                  readResult = read(result.data() + readBytes, result.size() - readBytes);
                  if (readResult > 0 || readBytes == 0)
                      readBytes += readResult;
              } while (readResult > 0);
          }
      

      As example when QIODevice::readData() makes a JNI call to InputStream.read() on Android Bluetooth system.

      May be need to insert

      if (result.size() != readBytes) break;
      

      to end of loop?

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

            tvete Paul Olav Tvete
            naugreem Boris Shmarin
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes