diff options
author | Aleksey Lysenko <lysenkoalexmail@gmail.com> | 2021-06-16 12:38:18 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-06-16 12:38:18 +0300 |
commit | 4715f63580f64d7baaba072f6c69632ccaa8a187 (patch) | |
tree | 201f42256d996e8aad25a70e929821d85e85011c /src/gui/selectivesyncdialog.cpp | |
parent | 09b538f4887d77685983dcb71d1ef6c1075a1b49 (diff) |
Remove possible qt containers detach (#8727)
* Replaced obsolete foreach-loops with for-loops
* Added a copy of queries into SqlDatabase::close
* Used const reference to avoid unneeded copying
* Fixed Qt containers possible detach within for-loop
* Removed unneeded copies before for-loops
Diffstat (limited to 'src/gui/selectivesyncdialog.cpp')
-rw-r--r-- | src/gui/selectivesyncdialog.cpp | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/gui/selectivesyncdialog.cpp b/src/gui/selectivesyncdialog.cpp index 1a2920f19..c9e60b33b 100644 --- a/src/gui/selectivesyncdialog.cpp +++ b/src/gui/selectivesyncdialog.cpp @@ -155,7 +155,7 @@ void SelectiveSyncWidget::recursiveInsert(QTreeWidgetItem *parent, QStringList p if (parent->checkState(0) == Qt::Checked || parent->checkState(0) == Qt::PartiallyChecked) { item->setCheckState(0, Qt::Checked); - foreach (const QString &str, _oldBlackList) { + for (const auto &str : qAsConst(_oldBlackList)) { if (str == path || str == QLatin1String("/")) { item->setCheckState(0, Qt::Unchecked); break; @@ -200,7 +200,7 @@ void SelectiveSyncWidget::slotUpdateDirectories(QStringList list) // list of top-level folders as soon as possible. if (_oldBlackList == QStringList("/")) { _oldBlackList.clear(); - foreach (QString path, list) { + for (auto path : qAsConst(list)) { path.remove(pathToRemove); if (path.isEmpty()) { continue; @@ -231,7 +231,7 @@ void SelectiveSyncWidget::slotUpdateDirectories(QStringList list) } Utility::sortFilenames(list); - foreach (QString path, list) { + for (auto path : qAsConst(list)) { auto size = job ? job->sizes().value(path) : 0; path.remove(pathToRemove); QStringList paths = path.split('/'); @@ -363,7 +363,7 @@ QStringList SelectiveSyncWidget::createBlackList(QTreeWidgetItem *root) const } else { // We did not load from the server so we re-use the one from the old black list QString path = root->data(0, Qt::UserRole).toString(); - foreach (const QString &it, _oldBlackList) { + for (const auto &it : _oldBlackList) { if (it.startsWith(path)) result += it; } @@ -470,8 +470,8 @@ void SelectiveSyncDialog::accept() //The part that changed should not be read from the DB on next sync because there might be new folders // (the ones that are no longer in the blacklist) auto blackListSet = blackList.toSet(); - auto changes = (oldBlackListSet - blackListSet) + (blackListSet - oldBlackListSet); - foreach (const auto &it, changes) { + const auto changes = (oldBlackListSet - blackListSet) + (blackListSet - oldBlackListSet); + for (const auto &it : changes) { _folder->journalDb()->schedulePathForRemoteDiscovery(it); _folder->schedulePathForLocalDiscovery(it); } |