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

QIODevice base function return values are not documented

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P2: Important
    • None
    • 5.15.2, 6.2.6, 6.4.1
    • Documentation
    • None
    • All

    Description

      The documentation for QIODevice is at:

       

      https://doc.qt.io/qt-5/qiodevice.html

      https://doc.qt.io/qt-6.2/qiodevice.html

      https://doc.qt.io/qt-6/qiodevice.html

       

      The return values of the base implementations of the various virtual functions are undocumented, which presents a fair amount of uncertainty when implementing QIODevice-derived classes.

       

      For example, QIODevice::isSequential currently reads:

       

      Returns true if this device is sequential; otherwise returns false.

      Sequential devices, as opposed to a random-access devices, have no concept of a start, an end, a size, or a current position, and they do not support seeking. You can only read from the device when it reports that data is available. The most common example of a sequential device is a network socket. On Unix, special files such as /dev/zero and fifo pipes are sequential.

      Regular files, on the other hand, do support random access. They have both a size and a current position, and they also support seeking backwards and forwards in the data stream. Regular files are non-sequential.

       

      Leaving one to wonder whether or not they should reimplement it for [non-]sequential QIODevices. 

      Notes similar to "the base implementation returns false" (or maybe it's true; not sure) could be added to the existing documentation.

      The other functions documented there are similar.

      There may be other classes in the documentation with similar issues. I find it to be particularly important for QIODevice, whose subclasses must exhibit very specific behaviors and invariants in order to function correctly.

      As a consequence, the only safe way to currently implement a QIODevice-subclass is to either implement every virtual function with a non-void return – which seems to counter the intent of the API (minimizing number of overrides needed) – or to dig into the Qt source to find the return values, both of which add a lot of potentially unnecessary work (= higher risk for mistakes).

      Attachments

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

        Activity

          People

            docteam Qt Documentation Team
            jasonc Jason Cipriani
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes