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

QCborStreamReader(QIODevice * dev) doesn't move the dev pos

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P2: Important
    • Resolution: Done
    • Affects Version/s: 5.12.4, 5.13.0
    • Fix Version/s: 5.12.5, 5.13.1, 5.14.0 Alpha
    • Component/s: Core: I/O
    • Labels:
      None
    • Commits:
      65f9646583d74c97aab7f8ea90197e370d7bfede (qt/qtbase/5.12)

      Description

      QCborStreamReader(QIODevice * dev) should move the dev pos to the end of the message after it reads the message, but it doesn't.

      The following code shows the problem:

          QBuffer buff;
          buff.open(QIODevice::ReadWrite);
          QCborStreamWriter writer(&buff);
          writer.startMap();
          writer.append(0);
          writer.append("Hi");
          writer.append(1);
          writer.append(0xffff);
          writer.append(2);
          writer.append(1.23);
          writer.endMap();
      
          auto oldPos = buff.pos();
          qDebug() << buff.pos();
          buff.seek(0);
          QCborStreamReader reader(&buff);
          QCborValue map = QCborValue::fromCbor(reader);
          if (reader.isLengthKnown())
              qDebug() << "length" << reader.length();
          qDebug() << oldPos << buff.pos() << (reader.lastError() == QCborError::NoError) << map[0].toString() << map[1].toInteger() << map[2].toDouble();
          Q_ASSERT(oldPos == buff.pos());
      

      The output of the previous code is:

      20
      length 18446744073709551615
      20 5 false "Hi" 65535 1.23
      ASSERT: "oldPos == buff.pos()" in file ../testStreaming/main.cpp, line 31
      

        Attachments

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

          Activity

            People

            • Assignee:
              thiago Thiago Macieira
              Reporter:
              taipan BogDan Vatra
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Gerrit Reviews

                There are no open Gerrit changes