From 34fe9232dbf6a9fe58ebc4c7680bb67d2f642c40 Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Mon, 10 Jun 2019 11:08:29 +0200 Subject: Port from QAtomic::load() to loadRelaxed() Semi-automated, just needed ~20 manual fixes: $ find \( -iname \*.cpp -or -iname \*.h \) -exec perl -pe 's/(\.|->)load\(\)/$1loadRelaxed\(\)/g' -i \{\} + $ find \( -iname \*.cpp -or -iname \*.h \) -exec perl -pe 's/(\.|->)store\(/$1storeRelaxed\(/g' -i \{\} + It can be easily improved (e.g. for store check that there are no commas after the opening parens). The most common offender is QLibrary::load, and some code using std::atomic directly. Change-Id: I07c38a3c8ed32c924ef4999e85c7e45cf48f0f6c Reviewed-by: Marc Mutz --- src/widgets/dialogs/qfileinfogatherer.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'src/widgets/dialogs') diff --git a/src/widgets/dialogs/qfileinfogatherer.cpp b/src/widgets/dialogs/qfileinfogatherer.cpp index 1e03ad8b06..f39ae2b53e 100644 --- a/src/widgets/dialogs/qfileinfogatherer.cpp +++ b/src/widgets/dialogs/qfileinfogatherer.cpp @@ -54,12 +54,12 @@ QT_BEGIN_NAMESPACE static QBasicAtomicInt fetchedRoot = Q_BASIC_ATOMIC_INITIALIZER(false); Q_AUTOTEST_EXPORT void qt_test_resetFetchedRoot() { - fetchedRoot.store(false); + fetchedRoot.storeRelaxed(false); } Q_AUTOTEST_EXPORT bool qt_test_isFetchedRoot() { - return fetchedRoot.load(); + return fetchedRoot.loadRelaxed(); } #endif @@ -111,7 +111,7 @@ QFileInfoGatherer::QFileInfoGatherer(QObject *parent) */ QFileInfoGatherer::~QFileInfoGatherer() { - abort.store(true); + abort.storeRelaxed(true); QMutexLocker locker(&mutex); condition.wakeAll(); locker.unlock(); @@ -247,9 +247,9 @@ void QFileInfoGatherer::run() { forever { QMutexLocker locker(&mutex); - while (!abort.load() && path.isEmpty()) + while (!abort.loadRelaxed() && path.isEmpty()) condition.wait(&mutex); - if (abort.load()) + if (abort.loadRelaxed()) return; const QString thisPath = qAsConst(path).front(); path.pop_front(); @@ -303,7 +303,7 @@ void QFileInfoGatherer::getFileInfos(const QString &path, const QStringList &fil // List drives if (path.isEmpty()) { #ifdef QT_BUILD_INTERNAL - fetchedRoot.store(true); + fetchedRoot.storeRelaxed(true); #endif QFileInfoList infoList; if (files.isEmpty()) { @@ -332,7 +332,7 @@ void QFileInfoGatherer::getFileInfos(const QString &path, const QStringList &fil QStringList allFiles; if (files.isEmpty()) { QDirIterator dirIt(path, QDir::AllEntries | QDir::System | QDir::Hidden); - while (!abort.load() && dirIt.hasNext()) { + while (!abort.loadRelaxed() && dirIt.hasNext()) { dirIt.next(); fileInfo = dirIt.fileInfo(); allFiles.append(fileInfo.fileName()); @@ -343,7 +343,7 @@ void QFileInfoGatherer::getFileInfos(const QString &path, const QStringList &fil emit newListOfFiles(path, allFiles); QStringList::const_iterator filesIt = filesToCheck.constBegin(); - while (!abort.load() && filesIt != filesToCheck.constEnd()) { + while (!abort.loadRelaxed() && filesIt != filesToCheck.constEnd()) { fileInfo.setFile(path + QDir::separator() + *filesIt); ++filesIt; fetch(fileInfo, base, firstTime, updatedFiles, path); -- cgit v1.2.3