From 53a2960353690b013d6fd99977904cb10afde1d2 Mon Sep 17 00:00:00 2001 From: "Friedrich W. H. Kossebau" Date: Tue, 18 Sep 2018 01:11:28 +0200 Subject: [PATCH] Avoid potential detach on range-loops with non-const Qt containers Seen by clazy range-loop --- src/plasma/private/theme_p.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/plasma/private/theme_p.cpp b/src/plasma/private/theme_p.cpp index a3fa5bf36..e5e3ac137 100644 --- a/src/plasma/private/theme_p.cpp +++ b/src/plasma/private/theme_p.cpp @@ -219,7 +219,8 @@ bool ThemePrivate::useCache() QDir cacheDir(QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation)); cacheDir.setNameFilters(QStringList({cacheFileBase})); - for (const QFileInfo &file : cacheDir.entryInfoList()) { + const auto files = cacheDir.entryInfoList(); + for (const QFileInfo &file : files) { if (currentCacheFileName.isEmpty() || !file.absoluteFilePath().endsWith(currentCacheFileName)) { QFile::remove(file.absoluteFilePath()); @@ -268,7 +269,8 @@ bool ThemePrivate::useCache() QDir cacheDir(QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation)); cacheDir.setNameFilters(QStringList({svgElementsFileNameBase + QLatin1Char('*')})); - for (const QFileInfo &file : cacheDir.entryInfoList()) { + const auto files = cacheDir.entryInfoList(); + for (const QFileInfo &file : files) { if (!file.absoluteFilePath().endsWith(svgElementsFileName)) { QFile::remove(file.absoluteFilePath()); }