From bbe79a3b98df27224a3464b4ab3fd6f16ac35711 Mon Sep 17 00:00:00 2001 From: Ahmad Samir Date: Thu, 27 Mar 2025 22:52:58 +0200 Subject: [PATCH] QDirIterator: add note about always calling hasNext() ... before using next/nextFileInfo(). That's both more logical and safer; this is analogous to always checking `iterator != end` before using said iterator. Change-Id: I87583f645087d34fc3e76e77f1ac168f76b6868e Reviewed-by: Thiago Macieira --- src/corelib/io/qdiriterator.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/corelib/io/qdiriterator.cpp b/src/corelib/io/qdiriterator.cpp index 7d7fe156845..a186d94a334 100644 --- a/src/corelib/io/qdiriterator.cpp +++ b/src/corelib/io/qdiriterator.cpp @@ -209,7 +209,8 @@ QDirIterator::~QDirIterator() /*! Advances the iterator to the next entry, and returns the file path of this new entry. If hasNext() returns \c false, this function does nothing, and - returns an empty QString. + returns an empty QString. Ideally you should always call hasNext() before + calling this method. You can call fileName() or filePath() to get the current entry's file name or path, or fileInfo() to get a QFileInfo for the current entry. @@ -229,7 +230,8 @@ QString QDirIterator::next() Advances the iterator to the next entry, and returns the file info of this new entry. If hasNext() returns \c false, this function does nothing, and - returns an empty QFileInfo. + returns an empty QFileInfo. Ideally you should always call hasNext() before + calling this method. You can call fileName() or filePath() to get the current entry's file name or path, or fileInfo() to get a QFileInfo for the current entry.