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

QDirIterator::next no longer returns "" upon iterator exhaustion

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3: Somewhat important P3: Somewhat important
    • 6.8.4, 6.9.1, 6.10.0 FF
    • 6.8.3
    • Core: I/O
    • None
    • Reproduced on macOS Sequoia 15.3.2, Windows 10 Version 1809
    • All
    • 4fd7d31e0 (dev), a6fc30f69 (dev), 03ac8f834 (6.9), 107c490a6 (6.8)

      QDirIterator::hasNext is the usual way to detect iterator exhaustion, but QDirIterator documentation says that ::next will return an empty string upon exhaustion.  In Qt 5 and up to 6.5.3 at least, this was true, so a loop controlled by while (it.next() != "") terminated normally.  In 6.8.3, that loop runs forever, with it.next() repeatedly returning the last filename ad infinitum, contrary to documentation at https://doc.qt.io/qt-6/qdiriterator.html#next.

      Naturally, code should be using it.hasNext(), but either your documentation or your library needs to change, as this is an apparent regression failure that could impact existing products as they upgrade to Qt 6.8.

      This bug is observed on macOS and Windows, but likely occurs on all platforms.

      Minimal example is attached.

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

            ahmad.samir Ahmad Samir
            barbicels- R Brown
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: