File 0001-properly-ignore-broken-unicode-filenames.patch of Package qt6-base
diff --git a/src/corelib/io/qfilesystemiterator_p.h b/src/corelib/io/qfilesystemiterator_p.h
index b8696f82cb4..52ba98dbb03 100644
--- a/src/corelib/io/qfilesystemiterator_p.h
+++ b/src/corelib/io/qfilesystemiterator_p.h
@@ -27,10 +27,6 @@
#include <QtCore/private/qfilesystementry_p.h>
#include <QtCore/private/qfilesystemmetadata_p.h>
-#if !defined(Q_OS_WIN)
-#include <private/qstringconverter_p.h>
-#endif
-
#include <memory>
QT_BEGIN_NAMESPACE
@@ -65,7 +61,6 @@ private:
QT_DIRENT *dirEntry = nullptr;
int lastError = 0;
- QStringDecoder toUtf16;
#endif
Q_DISABLE_COPY_MOVE(QFileSystemIterator)
diff --git a/src/corelib/io/qfilesystemiterator_unix.cpp b/src/corelib/io/qfilesystemiterator_unix.cpp
index 9fbe7f4d766..e4d5a60dd25 100644
--- a/src/corelib/io/qfilesystemiterator_unix.cpp
+++ b/src/corelib/io/qfilesystemiterator_unix.cpp
@@ -9,6 +9,8 @@
#include <qvarlengtharray.h>
+#include <private/qstringconverter_p.h>
+
#include <memory>
#include <stdlib.h>
@@ -21,8 +23,7 @@ QT_BEGIN_NAMESPACE
libraries to iterate over the directory represented by \a entry.
*/
QFileSystemIterator::QFileSystemIterator(const QFileSystemEntry &entry)
- : dirPath(entry.filePath()),
- toUtf16(QStringDecoder::Utf8)
+ : dirPath(entry.filePath())
{
dir.reset(QT_OPENDIR(entry.nativeFilePath().constData()));
if (!dir) {
@@ -75,6 +76,7 @@ std::optional<QDirEntryInfo> QFileSystemIterator::advance()
QByteArrayView name(dirEntry->d_name, strlen(dirEntry->d_name));
// name.size() is sufficient here, see QUtf8::convertToUnicode() for details
QVarLengthArray<char16_t> buffer(name.size());
+ QStringDecoder toUtf16(QStringDecoder::Utf8);
auto *end = toUtf16.appendToBuffer(buffer.data(), name);
buffer.resize(end - buffer.constData());
if (!toUtf16.hasError()) {