Don't hold ref to value returned from function.
authorHarald Eilertsen <haraldei@anduin.net>
Tue, 29 Sep 2020 16:32:48 +0000 (18:32 +0200)
committerHarald Eilertsen <haraldei@anduin.net>
Tue, 29 Sep 2020 17:32:24 +0000 (19:32 +0200)
Signed-off-by: Harald Eilertsen <haraldei@anduin.net>
src/gui/accountsettings.cpp
src/gui/accountstate.cpp
src/gui/application.cpp
src/gui/folder.cpp
src/gui/folderman.cpp

index 62491c5dbe5ed1e9394ef6027cc84ec3a7c97716..49e90e19b90430bd956a8eb94328f9105b89728e 100644 (file)
@@ -761,7 +761,7 @@ void AccountSettings::slotAccountStateChanged()
         AccountPtr account = _accountState->account();
         QUrl safeUrl(account->url());
         safeUrl.setPassword(QString()); // Remove the password from the URL to avoid showing it in the UI
-        const auto &folders = FolderMan::instance()->map().values();
+        const auto folders = FolderMan::instance()->map().values();
         for (Folder *folder : folders) {
             _model->slotUpdateFolderState(folder);
         }
@@ -894,14 +894,14 @@ void AccountSettings::refreshSelectiveSyncStatus()
 
     QString msg;
     int cnt = 0;
-    const auto &folders = FolderMan::instance()->map().values();
+    const auto folders = FolderMan::instance()->map().values();
     for (Folder *folder : folders) {
         if (folder->accountState() != _accountState) {
             continue;
         }
 
         bool ok = false;
-        const auto &undecidedList = folder->journalDb()->getSelectiveSyncList(SyncJournalDb::SelectiveSyncUndecidedList, &ok);
+        const auto undecidedList = folder->journalDb()->getSelectiveSyncList(SyncJournalDb::SelectiveSyncUndecidedList, &ok);
         QString p;
         for (const auto &it : undecidedList) {
             // FIXME: add the folder alias in a hoover hint.
index be8b9087685f2ffcebc10b42abf7b6c97b9d9616..58a6790318322230d5a2f8ff6bc26abb48d66f96 100644 (file)
@@ -441,7 +441,7 @@ void AccountState::slotNavigationAppsFetched(const QJsonDocument &reply, int sta
 
             if(!reply.isEmpty()){
                 auto element = reply.object().value("ocs").toObject().value("data");
-                const auto &navLinks = element.toArray();
+                const auto navLinks = element.toArray();
 
                 if(navLinks.size() > 0){
                     for (const QJsonValue &value : navLinks) {
@@ -468,7 +468,7 @@ AccountAppList AccountState::appList() const
 AccountApp* AccountState::findApp(const QString &appId) const
 {
     if(!appId.isEmpty()) {
-        const auto &apps = appList();
+        const auto apps = appList();
         const auto it = std::find_if(apps.cbegin(), apps.cend(), [appId](const auto &app) {
             return app->id() == appId;
         });
index ca42c0cc4755c9220f89372965a7f962abf6b716..9ac569cbc8c3efe973ebf9d112bc919058caafd3 100644 (file)
@@ -349,7 +349,7 @@ void Application::slotSystemOnlineConfigurationChanged(QNetworkConfiguration cnf
 
 void Application::slotCheckConnection()
 {
-    const auto &list = AccountManager::instance()->accounts();
+    const auto list = AccountManager::instance()->accounts();
     for (const auto &accountState : list) {
         AccountState::State state = accountState->state();
 
index 85bfcee4d564a4885b7d4b6308a84f467b1900d4..b4bfab3e6e1984182f01e07252a32ba85d37123a 100644 (file)
@@ -528,7 +528,7 @@ void Folder::saveToSettings() const
     // This ensures that older clients will not read a configuration
     // where two folders for different accounts point at the same
     // local folders.
-    const auto &folderMap = FolderMan::instance()->map();
+    const auto folderMap = FolderMan::instance()->map();
     const auto it = std::find_if(folderMap.cbegin(), folderMap.cend(), [this](const auto *other) {
         return other != this && other->cleanPath() == this->cleanPath();
     });
index 472be06633009409637b6f7957cb672521c14920..92a842488326977d3afa394d348bb65f96b44801 100755 (executable)
@@ -280,7 +280,7 @@ int FolderMan::setupFoldersMigration()
     QDir dir(_folderConfigPath);
     //We need to include hidden files just in case the alias starts with '.'
     dir.setFilter(QDir::Files | QDir::Hidden);
-    const auto &list = dir.entryList();
+    const auto list = dir.entryList();
 
     // Normally there should be only one account when migrating.
     AccountState *accountState = AccountManager::instance()->accounts().value(0).data();
@@ -913,7 +913,7 @@ Folder *FolderMan::addFolder(AccountState *accountState, const FolderDefinition
 
     // Migration: The first account that's configured for a local folder shall
     // be saved in a backwards-compatible way.
-    const auto &folderList = FolderMan::instance()->map();
+    const auto folderList = FolderMan::instance()->map();
     const auto it = std::find_if(folderList.cbegin(), folderList.cend(), [this, folder](const auto *other) {
         return other != folder && other->cleanPath() == folder->cleanPath();
     });
@@ -975,7 +975,7 @@ Folder *FolderMan::folderForPath(const QString &path)
 {
     QString absolutePath = QDir::cleanPath(path) + QLatin1Char('/');
 
-    const auto &folders = this->map().values();
+    const auto folders = this->map().values();
     const auto it = std::find_if(folders.cbegin(), folders.cend(), [absolutePath](const auto *folder) {
         const QString folderPath = folder->cleanPath() + QLatin1Char('/');
         return absolutePath.startsWith(folderPath, (Utility::isWindows() || Utility::isMac()) ? Qt::CaseInsensitive : Qt::CaseSensitive);