diff options
Diffstat (limited to 'src/corelib/io')
-rw-r--r-- | src/corelib/io/forkfd_qt.cpp | 2 | ||||
-rw-r--r-- | src/corelib/io/qdiriterator.cpp | 38 | ||||
-rw-r--r-- | src/corelib/io/qfilesystemwatcher.cpp | 2 | ||||
-rw-r--r-- | src/corelib/io/qfilesystemwatcher_fsevents.mm | 30 | ||||
-rw-r--r-- | src/corelib/io/qprocess_unix.cpp | 2 | ||||
-rw-r--r-- | src/corelib/io/qresource.cpp | 4 | ||||
-rw-r--r-- | src/corelib/io/qsettings.cpp | 4 | ||||
-rw-r--r-- | src/corelib/io/qstorageinfo_unix.cpp | 4 | ||||
-rw-r--r-- | src/corelib/io/qtemporaryfile_p.h | 6 |
9 files changed, 54 insertions, 38 deletions
diff --git a/src/corelib/io/forkfd_qt.cpp b/src/corelib/io/forkfd_qt.cpp index dce0ebb4da..80d1cd54d7 100644 --- a/src/corelib/io/forkfd_qt.cpp +++ b/src/corelib/io/forkfd_qt.cpp @@ -56,8 +56,6 @@ QT_BEGIN_NAMESPACE #define FFD_ATOMIC_RELAXED Relaxed #define FFD_ATOMIC_ACQUIRE Acquire #define FFD_ATOMIC_RELEASE Release -#define loadRelaxed load -#define storeRelaxed store #define FFD_CONCAT(x, y) x ## y diff --git a/src/corelib/io/qdiriterator.cpp b/src/corelib/io/qdiriterator.cpp index 21214ee273..303caf29a4 100644 --- a/src/corelib/io/qdiriterator.cpp +++ b/src/corelib/io/qdiriterator.cpp @@ -97,6 +97,9 @@ #include <QtCore/qset.h> #include <QtCore/qstack.h> #include <QtCore/qvariant.h> +#if QT_CONFIG(regularexpression) +#include <QtCore/qregularexpression.h> +#endif #include <QtCore/private/qfilesystemiterator_p.h> #include <QtCore/private/qfilesystementry_p.h> @@ -136,8 +139,11 @@ public: const QDir::Filters filters; const QDirIterator::IteratorFlags iteratorFlags; -#ifndef QT_NO_REGEXP +#if defined(QT_BOOTSTRAPPED) + // ### Qt6: Get rid of this once we don't bootstrap qmake anymore QVector<QRegExp> nameRegExps; +#elif QT_CONFIG(regularexpression) + QVector<QRegularExpression> nameRegExps; #endif QDirIteratorPrivateIteratorStack<QAbstractFileEngineIterator> fileEngineIterators; @@ -162,13 +168,21 @@ QDirIteratorPrivate::QDirIteratorPrivate(const QFileSystemEntry &entry, const QS , filters(QDir::NoFilter == filters ? QDir::AllEntries : filters) , iteratorFlags(flags) { -#ifndef QT_NO_REGEXP +#if defined(QT_BOOTSTRAPPED) nameRegExps.reserve(nameFilters.size()); - for (int i = 0; i < nameFilters.size(); ++i) + for (const auto &filter : nameFilters) { nameRegExps.append( - QRegExp(nameFilters.at(i), + QRegExp(filter, (filters & QDir::CaseSensitive) ? Qt::CaseSensitive : Qt::CaseInsensitive, QRegExp::Wildcard)); + } +#elif QT_CONFIG(regularexpression) + nameRegExps.reserve(nameFilters.size()); + for (const auto &filter : nameFilters) { + QString re = QRegularExpression::anchoredPattern(QRegularExpression::wildcardToRegularExpression(filter)); + nameRegExps.append( + QRegularExpression(re, (filters & QDir::CaseSensitive) ? QRegularExpression::NoPatternOption : QRegularExpression::CaseInsensitiveOption)); + } #endif QFileSystemMetaData metaData; if (resolveEngine) @@ -335,19 +349,23 @@ bool QDirIteratorPrivate::matchesFilters(const QString &fileName, const QFileInf return false; // name filter -#ifndef QT_NO_REGEXP +#if QT_CONFIG(regularexpression) || defined(QT_BOOTSTRAPPED) // Pass all entries through name filters, except dirs if the AllDirs if (!nameFilters.isEmpty() && !((filters & QDir::AllDirs) && fi.isDir())) { bool matched = false; - for (QVector<QRegExp>::const_iterator iter = nameRegExps.constBegin(), - end = nameRegExps.constEnd(); - iter != end; ++iter) { - - QRegExp copy = *iter; + for (const auto &re : nameRegExps) { +#if defined(QT_BOOTSTRAPPED) + QRegExp copy = re; if (copy.exactMatch(fileName)) { matched = true; break; } +#else + if (re.match(fileName).hasMatch()) { + matched = true; + break; + } +#endif } if (!matched) return false; diff --git a/src/corelib/io/qfilesystemwatcher.cpp b/src/corelib/io/qfilesystemwatcher.cpp index e3e4433a6b..64c422c55a 100644 --- a/src/corelib/io/qfilesystemwatcher.cpp +++ b/src/corelib/io/qfilesystemwatcher.cpp @@ -47,7 +47,7 @@ #include <qset.h> #include <qtimer.h> -#if defined(Q_OS_LINUX) || (defined(Q_OS_QNX) && !defined(QT_NO_INOTIFY)) +#if (defined(Q_OS_LINUX) || defined(Q_OS_QNX)) && QT_CONFIG(inotify) #define USE_INOTIFY #endif diff --git a/src/corelib/io/qfilesystemwatcher_fsevents.mm b/src/corelib/io/qfilesystemwatcher_fsevents.mm index fb3b6f86fd..6194bf7c71 100644 --- a/src/corelib/io/qfilesystemwatcher_fsevents.mm +++ b/src/corelib/io/qfilesystemwatcher_fsevents.mm @@ -50,6 +50,7 @@ #include <qfile.h> #include <qfileinfo.h> #include <qvarlengtharray.h> +#include <qscopeguard.h> #undef FSEVENT_DEBUG #ifdef FSEVENT_DEBUG @@ -338,10 +339,10 @@ QStringList QFseventsFileSystemWatcherEngine::addPaths(const QStringList &paths, bool needsRestart = false; WatchingState oldState = watchingState; - QStringList p = paths; - QMutableListIterator<QString> it(p); - while (it.hasNext()) { - QString origPath = it.next().normalized(QString::NormalizationForm_C); + QStringList unhandled; + for (const QString &path : paths) { + auto sg = qScopeGuard([&]{ unhandled.push_back(path); }); + QString origPath = path.normalized(QString::NormalizationForm_C); QString realPath = origPath; if (realPath.endsWith(QDir::separator())) realPath = realPath.mid(0, realPath.size() - 1); @@ -362,17 +363,17 @@ QStringList QFseventsFileSystemWatcherEngine::addPaths(const QStringList &paths, continue; directories->append(origPath); watchedPath = realPath; - it.remove(); } else { if (files->contains(origPath)) continue; files->append(origPath); - it.remove(); watchedPath = fi.path(); parentPath = watchedPath; } + sg.dismiss(); + for (PathRefCounts::const_iterator i = watchingState.watchedPaths.begin(), ei = watchingState.watchedPaths.end(); i != ei; ++i) { if (watchedPath.startsWith(i.key() % QDir::separator())) { @@ -409,14 +410,14 @@ QStringList QFseventsFileSystemWatcherEngine::addPaths(const QStringList &paths, // ok, something went wrong, let's try to restore the previous state watchingState = std::move(oldState); // and because we don't know which path caused the issue (if any), fail on all of them - p = paths; + unhandled = paths; if (wasRunning) startStream(); } } - return p; + return unhandled; } QStringList QFseventsFileSystemWatcherEngine::removePaths(const QStringList &paths, @@ -430,10 +431,9 @@ QStringList QFseventsFileSystemWatcherEngine::removePaths(const QStringList &pat bool needsRestart = false; WatchingState oldState = watchingState; - QStringList p = paths; - QMutableListIterator<QString> it(p); - while (it.hasNext()) { - QString origPath = it.next(); + QStringList unhandled; + for (const QString &origPath : paths) { + auto sg = qScopeGuard([&]{ unhandled.push_back(origPath); }); QString realPath = origPath; if (realPath.endsWith(QDir::separator())) realPath = realPath.mid(0, realPath.size() - 1); @@ -447,7 +447,7 @@ QStringList QFseventsFileSystemWatcherEngine::removePaths(const QStringList &pat needsRestart |= derefPath(dirIt->dirInfo.watchedPath); watchingState.watchedDirectories.erase(dirIt); directories->removeAll(origPath); - it.remove(); + sg.dismiss(); DEBUG("Removed directory '%s'", qPrintable(realPath)); } } else { @@ -463,7 +463,7 @@ QStringList QFseventsFileSystemWatcherEngine::removePaths(const QStringList &pat if (filesInDir.isEmpty()) watchingState.watchedFiles.erase(pIt); files->removeAll(origPath); - it.remove(); + sg.dismiss(); DEBUG("Removed file '%s'", qPrintable(realPath)); } } @@ -479,7 +479,7 @@ QStringList QFseventsFileSystemWatcherEngine::removePaths(const QStringList &pat } } - return p; + return unhandled; } // Returns false if FSEventStream* calls failed for some mysterious reason, true if things got a diff --git a/src/corelib/io/qprocess_unix.cpp b/src/corelib/io/qprocess_unix.cpp index 3a29a0d842..1d5b76a8a4 100644 --- a/src/corelib/io/qprocess_unix.cpp +++ b/src/corelib/io/qprocess_unix.cpp @@ -517,7 +517,7 @@ void QProcessPrivate::startProcess() if (stderrChannel.pipe[0] != -1) ::fcntl(stderrChannel.pipe[0], F_SETFL, ::fcntl(stderrChannel.pipe[0], F_GETFL) | O_NONBLOCK); - if (threadData->eventDispatcher) { + if (threadData->eventDispatcher.loadAcquire()) { deathNotifier = new QSocketNotifier(forkfd, QSocketNotifier::Read, q); QObject::connect(deathNotifier, SIGNAL(activated(int)), q, SLOT(_q_processDied())); diff --git a/src/corelib/io/qresource.cpp b/src/corelib/io/qresource.cpp index d143f7fda3..fcc5b69179 100644 --- a/src/corelib/io/qresource.cpp +++ b/src/corelib/io/qresource.cpp @@ -197,13 +197,13 @@ Q_DECLARE_TYPEINFO(QResourceRoot, Q_MOVABLE_TYPE); typedef QList<QResourceRoot*> ResourceList; struct QResourceGlobalData { - QMutex resourceMutex{QMutex::Recursive}; + QRecursiveMutex resourceMutex; ResourceList resourceList; QStringList resourceSearchPaths; }; Q_GLOBAL_STATIC(QResourceGlobalData, resourceGlobalData) -static inline QMutex *resourceMutex() +static inline QRecursiveMutex *resourceMutex() { return &resourceGlobalData->resourceMutex; } static inline ResourceList *resourceList() diff --git a/src/corelib/io/qsettings.cpp b/src/corelib/io/qsettings.cpp index 9234a23f3a..accde01f16 100644 --- a/src/corelib/io/qsettings.cpp +++ b/src/corelib/io/qsettings.cpp @@ -2048,8 +2048,8 @@ void QConfFileSettingsPrivate::ensureSectionParsed(QConfFile *confFile, QPixmap, which are part of Qt GUI. In other words, there is no \c toColor(), \c toImage(), or \c toPixmap() functions in QVariant. - Instead, you can use the QVariant::value() or the qVariantValue() - template function. For example: + Instead, you can use the QVariant::value() template function. + For example: \snippet code/src_corelib_io_qsettings.cpp 0 diff --git a/src/corelib/io/qstorageinfo_unix.cpp b/src/corelib/io/qstorageinfo_unix.cpp index b6413d7902..4669c20711 100644 --- a/src/corelib/io/qstorageinfo_unix.cpp +++ b/src/corelib/io/qstorageinfo_unix.cpp @@ -220,7 +220,7 @@ static bool shouldIncludeFs(const QStorageIterator &it) return false; } -#ifdef Q_OS_LINUX +#if defined(Q_OS_LINUX) && !defined(Q_OS_ANDROID) if (it.fileSystemType() == "rootfs") return false; #endif @@ -849,7 +849,7 @@ QList<QStorageInfo> QStorageInfoPrivate::mountedVolumes() info.d->device = it.device(); info.d->fileSystemType = it.fileSystemType(); info.d->subvolume = it.subvolume(); - if (info.bytesTotal() == 0) + if (info.bytesTotal() == 0 && info != root()) continue; volumes.append(info); } diff --git a/src/corelib/io/qtemporaryfile_p.h b/src/corelib/io/qtemporaryfile_p.h index 0fec88d3cd..6bcff936b4 100644 --- a/src/corelib/io/qtemporaryfile_p.h +++ b/src/corelib/io/qtemporaryfile_p.h @@ -145,10 +145,10 @@ public: bool isUnnamedFile() const override final; const QString &templateName; - quint32 fileMode; + quint32 fileMode = 0; int flags = 0; - bool filePathIsTemplate; - bool filePathWasTemplate; + bool filePathIsTemplate = true; + bool filePathWasTemplate = true; bool unnamedFile = false; }; |