From 0b76e35c042ff725372f9d82506767a8377ca147 Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Thu, 28 Nov 2024 16:55:12 +0800 Subject: [PATCH 01/22] Replace all uses of qAsConst with std::as_const Fixes deprecation warnings on Qt 6.8.0 Signed-off-by: Claudio Cambra --- .../kmessagewidget/kmessagewidget.cpp | 2 +- src/cmd/simplesslerrorhandler.cpp | 4 ++-- src/gui/accountmanager.cpp | 2 +- src/gui/application.cpp | 2 +- src/gui/editlocallyjob.cpp | 2 +- src/gui/filedetails/sharemodel.cpp | 4 ++-- src/gui/folder.cpp | 2 +- src/gui/folderman.cpp | 24 +++++++++---------- src/gui/folderstatusmodel.cpp | 4 ++-- src/gui/navigationpanehelper.cpp | 6 ++--- src/gui/owncloudgui.cpp | 2 +- src/gui/socketapi/socketapi.cpp | 6 ++--- src/gui/syncconflictsmodel.cpp | 4 ++-- .../tray/unifiedsearchresultslistmodel.cpp | 4 ++-- src/gui/tray/usermodel.cpp | 6 ++--- src/libsync/discovery.cpp | 2 +- src/libsync/owncloudpropagator.cpp | 2 +- src/libsync/propagateuploadng.cpp | 2 +- src/libsync/syncengine.cpp | 14 +++++------ src/libsync/syncfilestatustracker.cpp | 2 +- src/libsync/vfs/cfapi/cfapiwrapper.cpp | 2 +- 21 files changed, 49 insertions(+), 49 deletions(-) diff --git a/src/3rdparty/kmessagewidget/kmessagewidget.cpp b/src/3rdparty/kmessagewidget/kmessagewidget.cpp index 70d5941391b5c..bbc8cf41f72d3 100644 --- a/src/3rdparty/kmessagewidget/kmessagewidget.cpp +++ b/src/3rdparty/kmessagewidget/kmessagewidget.cpp @@ -154,7 +154,7 @@ void KMessageWidgetPrivate::createLayout() layout->addWidget(iconLabel); layout->addWidget(textLabel); - for (QToolButton *button : qAsConst(buttons)) { + for (QToolButton *button : std::as_const(buttons)) { layout->addWidget(button); } diff --git a/src/cmd/simplesslerrorhandler.cpp b/src/cmd/simplesslerrorhandler.cpp index f471403aa4145..50d55978eeac4 100644 --- a/src/cmd/simplesslerrorhandler.cpp +++ b/src/cmd/simplesslerrorhandler.cpp @@ -27,7 +27,7 @@ bool SimpleSslErrorHandler::handleErrors(QList errors, const QSslConf } if (account->trustCertificates()) { - for (const auto &error : qAsConst(errors)) { + for (const auto &error : std::as_const(errors)) { certs->append(error.certificate()); } return true; @@ -35,7 +35,7 @@ bool SimpleSslErrorHandler::handleErrors(QList errors, const QSslConf bool allTrusted = true; - for (const auto &error : qAsConst(errors)) { + for (const auto &error : std::as_const(errors)) { if (!account->approvedCerts().contains(error.certificate())) { allTrusted = false; } diff --git a/src/gui/accountmanager.cpp b/src/gui/accountmanager.cpp index a661f3eb3f253..ccfcfec4cbd0f 100644 --- a/src/gui/accountmanager.cpp +++ b/src/gui/accountmanager.cpp @@ -306,7 +306,7 @@ void AccountManager::save(bool saveCredentials) { const auto settings = ConfigFile::settingsWithGroup(QLatin1String(accountsC)); settings->setValue(QLatin1String(versionC), maxAccountsVersion); - for (const auto &acc : qAsConst(_accounts)) { + for (const auto &acc : std::as_const(_accounts)) { settings->beginGroup(acc->account()->id()); saveAccountHelper(acc->account().data(), *settings, saveCredentials); settings->endGroup(); diff --git a/src/gui/application.cpp b/src/gui/application.cpp index 1bf8cffea81ef..dcac6ad3234fc 100644 --- a/src/gui/application.cpp +++ b/src/gui/application.cpp @@ -199,7 +199,7 @@ bool Application::configVersionMigration() settings->endGroup(); // Wipe confusing keys from the future, ignore the others - for (const auto &badKey : qAsConst(deleteKeys)) { + for (const auto &badKey : std::as_const(deleteKeys)) { settings->remove(badKey); } } diff --git a/src/gui/editlocallyjob.cpp b/src/gui/editlocallyjob.cpp index 07a1d8f2afb7c..cac6de6d12ec2 100644 --- a/src/gui/editlocallyjob.cpp +++ b/src/gui/editlocallyjob.cpp @@ -514,7 +514,7 @@ void EditLocallyJob::lockFile(const QString &etag) void EditLocallyJob::disconnectFolderSignals() { - for (const auto &connection : qAsConst(_folderConnections)) { + for (const auto &connection : std::as_const(_folderConnections)) { disconnect(connection); } } diff --git a/src/gui/filedetails/sharemodel.cpp b/src/gui/filedetails/sharemodel.cpp index a199231998ad7..73441a0627b29 100644 --- a/src/gui/filedetails/sharemodel.cpp +++ b/src/gui/filedetails/sharemodel.cpp @@ -385,7 +385,7 @@ void ShareModel::handlePlaceholderLinkShare() auto linkSharePresent = false; auto placeholderLinkSharePresent = false; - for (const auto &share : qAsConst(_shares)) { + for (const auto &share : std::as_const(_shares)) { const auto shareType = share->getShareType(); if (!linkSharePresent && shareType == Share::TypeLink) { @@ -415,7 +415,7 @@ void ShareModel::handleSecureFileDropLinkShare() auto linkSharePresent = false; auto secureFileDropLinkSharePresent = false; - for (const auto &share : qAsConst(_shares)) { + for (const auto &share : std::as_const(_shares)) { const auto shareType = share->getShareType(); if (!linkSharePresent && shareType == Share::TypeLink) { diff --git a/src/gui/folder.cpp b/src/gui/folder.cpp index 6b7f2ad45fc34..fffbb11e5eaec 100644 --- a/src/gui/folder.cpp +++ b/src/gui/folder.cpp @@ -1760,7 +1760,7 @@ void Folder::removeLocalE2eFiles() const auto existingBlacklistSet = QSet{existingBlacklist.begin(), existingBlacklist.end()}; auto expandedBlacklistSet = QSet{existingBlacklist.begin(), existingBlacklist.end()}; - for (const auto &path : qAsConst(e2eFoldersToBlacklist)) { + for (const auto &path : std::as_const(e2eFoldersToBlacklist)) { expandedBlacklistSet.insert(path); } diff --git a/src/gui/folderman.cpp b/src/gui/folderman.cpp index a23a398270162..641cdbc19a007 100644 --- a/src/gui/folderman.cpp +++ b/src/gui/folderman.cpp @@ -226,7 +226,7 @@ int FolderMan::setupFolders() emit folderListChanged(_folderMap); - for (const auto folder : qAsConst(_folderMap)) { + for (const auto folder : std::as_const(_folderMap)) { folder->processSwitchedToVirtualFiles(); } @@ -768,7 +768,7 @@ void FolderMan::slotRunOneEtagJob() { if (_currentEtagJob.isNull()) { Folder *folder = nullptr; - for (Folder *f : qAsConst(_folderMap)) { + for (Folder *f : std::as_const(_folderMap)) { if (f->etagJob()) { // Caveat: always grabs the first folder with a job, but we think this is Ok for now and avoids us having a separate queue. _currentEtagJob = f->etagJob(); @@ -898,7 +898,7 @@ void FolderMan::startScheduledSyncSoon() void FolderMan::slotStartScheduledFolderSync() { if (isAnySyncRunning()) { - for (auto f : qAsConst(_folderMap)) { + for (auto f : std::as_const(_folderMap)) { if (f->isSyncRunning()) qCInfo(lcFolderMan) << "Currently folder " << f->remoteUrl().toString() << " is running, wait for finish!"; } @@ -1028,12 +1028,12 @@ void FolderMan::runEtagJobIfPossible(Folder *folder) void FolderMan::slotAccountRemoved(AccountState *accountState) { QVector foldersToRemove; - for (const auto &folder : qAsConst(_folderMap)) { + for (const auto &folder : std::as_const(_folderMap)) { if (folder->accountState() == accountState) { foldersToRemove.push_back(folder); } } - for (const auto &folder : qAsConst(foldersToRemove)) { + for (const auto &folder : std::as_const(foldersToRemove)) { removeFolder(folder); } } @@ -1050,7 +1050,7 @@ void FolderMan::slotRemoveFoldersForAccount(AccountState *accountState) } } - for (const auto &f : qAsConst(foldersToRemove)) { + for (const auto &f : std::as_const(foldersToRemove)) { removeFolder(f); } emit folderListChanged(_folderMap); @@ -1070,7 +1070,7 @@ void FolderMan::slotServerVersionChanged(Account *account) qCWarning(lcFolderMan) << "The server version is unsupported:" << account->serverVersion() << "pausing all folders on the account"; - for (auto &f : qAsConst(_folderMap)) { + for (auto &f : std::as_const(_folderMap)) { if (f->accountState()->account().data() == account) { f->setSyncPaused(true); } @@ -1088,7 +1088,7 @@ void FolderMan::slotWatchedFileUnlocked(const QString &path) void FolderMan::slotScheduleFolderByTime() { - for (const auto &f : qAsConst(_folderMap)) { + for (const auto &f : std::as_const(_folderMap)) { // Never schedule if syncing is disabled or when we're currently // querying the server for etags if (!f->canSync() || f->etagJob()) { @@ -1462,7 +1462,7 @@ void FolderMan::slotWipeFolderForAccount(AccountState *accountState) } bool success = false; - for (const auto &f : qAsConst(foldersToRemove)) { + for (const auto &f : std::as_const(foldersToRemove)) { if (!f) { qCCritical(lcFolderMan) << "Can not remove null folder"; return; @@ -1665,7 +1665,7 @@ void FolderMan::trayOverallStatus(const QList &folders, auto runSeen = false; auto various = false; - for (const Folder *folder : qAsConst(folders)) { + for (const Folder *folder : std::as_const(folders)) { // We've already seen an error, worst case met. // No need to check the remaining folders. if (errorsSeen) { @@ -1967,7 +1967,7 @@ void FolderMan::setIgnoreHiddenFiles(bool ignore) { // Note that the setting will revert to 'true' if all folders // are deleted... - for (Folder *folder : qAsConst(_folderMap)) { + for (Folder *folder : std::as_const(_folderMap)) { folder->setIgnoreHiddenFiles(ignore); folder->saveToSettings(); } @@ -2015,7 +2015,7 @@ void FolderMan::slotProcessFilesPushNotification(Account *account) { qCInfo(lcFolderMan) << "Got files push notification for account" << account; - for (auto folder : qAsConst(_folderMap)) { + for (auto folder : std::as_const(_folderMap)) { // Just run on the folders that belong to this account if (folder->accountState()->account() != account) { continue; diff --git a/src/gui/folderstatusmodel.cpp b/src/gui/folderstatusmodel.cpp index 44b2402c43c4f..91808fc48c122 100644 --- a/src/gui/folderstatusmodel.cpp +++ b/src/gui/folderstatusmodel.cpp @@ -833,7 +833,7 @@ void FolderStatusModel::slotUpdateDirectories(const QStringList &list) endInsertRows(); } - for (const auto undecidedIndex : qAsConst(undecidedIndexes)) { + for (const auto undecidedIndex : std::as_const(undecidedIndexes)) { emit suggestExpand(index(undecidedIndex, 0, parentIdx)); } /* Try to remove from the undecided lists the items that are not on the server. */ @@ -916,7 +916,7 @@ void FolderStatusModel::slotUpdateFolderState(Folder *folder) void FolderStatusModel::slotApplySelectiveSync() { - for (const auto &folderInfo : qAsConst(_folders)) { + for (const auto &folderInfo : std::as_const(_folders)) { if (!folderInfo._fetched) { folderInfo._folder->journalDb()->setSelectiveSyncList(SyncJournalDb::SelectiveSyncUndecidedList, QStringList()); continue; diff --git a/src/gui/navigationpanehelper.cpp b/src/gui/navigationpanehelper.cpp index cf792084acd2b..027d0ddeaa796 100644 --- a/src/gui/navigationpanehelper.cpp +++ b/src/gui/navigationpanehelper.cpp @@ -48,7 +48,7 @@ void NavigationPaneHelper::setShowInExplorerNavigationPane(bool show) _showInExplorerNavigationPane = show; // Re-generate a new CLSID when enabling, possibly throwing away the old one. // updateCloudStorageRegistry will take care of removing any unknown CLSID our application owns from the registry. - for (const auto &folder : qAsConst(_folderMan->map())) { + for (const auto &folder : std::as_const(_folderMan->map())) { folder->setNavigationPaneClsid(show ? QUuid::createUuid() : QUuid()); } @@ -89,7 +89,7 @@ void NavigationPaneHelper::updateCloudStorageRegistry() // Then re-save every folder that has a valid navigationPaneClsid to the registry. // We currently don't distinguish between new and existing CLSIDs, if it's there we just // save over it. We at least need to update the tile in case we are suddently using multiple accounts. - for (const auto &folder : qAsConst(_folderMan->map())) { + for (const auto &folder : std::as_const(_folderMan->map())) { if (!folder->navigationPaneClsid().isNull()) { // If it already exists, unmark it for removal, this is a valid sync root. entriesToRemove.removeOne(folder->navigationPaneClsid()); @@ -161,7 +161,7 @@ void NavigationPaneHelper::updateCloudStorageRegistry() } // Then remove anything that isn't in our folder list anymore. - for (const auto &clsid : qAsConst(entriesToRemove)) { + for (const auto &clsid : std::as_const(entriesToRemove)) { const auto clsidStr = clsid.toString(); const QString clsidPath = QString() % R"(Software\Classes\CLSID\)" % clsidStr; const QString clsidPathWow64 = QString() % R"(Software\Classes\Wow6432Node\CLSID\)" % clsidStr; diff --git a/src/gui/owncloudgui.cpp b/src/gui/owncloudgui.cpp index dccdcc3a8c7f9..7323a8d5b4a8a 100644 --- a/src/gui/owncloudgui.cpp +++ b/src/gui/owncloudgui.cpp @@ -361,7 +361,7 @@ void ownCloudGui::slotComputeOverallSyncStatus() #else QStringList messages; messages.append(tr("Disconnected from accounts:")); - for (const auto &accountState : qAsConst(problemAccounts)) { + for (const auto &accountState : std::as_const(problemAccounts)) { QString message = tr("Account %1: %2").arg(accountState->account()->displayName(), accountState->stateString(accountState->state())); if (!accountState->connectionErrors().empty()) { message += QLatin1String("\n"); diff --git a/src/gui/socketapi/socketapi.cpp b/src/gui/socketapi/socketapi.cpp index 071ae448b3814..cf47d3f5bcd5e 100644 --- a/src/gui/socketapi/socketapi.cpp +++ b/src/gui/socketapi/socketapi.cpp @@ -472,7 +472,7 @@ void SocketApi::slotRegisterPath(const QString &alias) Folder *f = FolderMan::instance()->folder(alias); if (f) { const QString message = buildRegisterPathMessage(removeTrailingSlash(f->path())); - for (const auto &listener : qAsConst(_listeners)) { + for (const auto &listener : std::as_const(_listeners)) { qCInfo(lcSocketApi) << "Trying to send SocketAPI Register Path Message -->" << message << "to" << listener->socket; listener->sendMessage(message); } @@ -519,7 +519,7 @@ void SocketApi::slotUpdateFolderView(Folder *f) void SocketApi::broadcastMessage(const QString &msg, bool doWait) { - for (const auto &listener : qAsConst(_listeners)) { + for (const auto &listener : std::as_const(_listeners)) { listener->sendMessage(msg, doWait); } } @@ -639,7 +639,7 @@ void SocketApi::broadcastStatusPushMessage(const QString &systemPath, SyncFileSt QString msg = buildMessage(QLatin1String("STATUS"), systemPath, fileStatus.toSocketAPIString()); Q_ASSERT(!systemPath.endsWith('/')); uint directoryHash = qHash(systemPath.left(systemPath.lastIndexOf('/'))); - for (const auto &listener : qAsConst(_listeners)) { + for (const auto &listener : std::as_const(_listeners)) { listener->sendMessageIfDirectoryMonitored(msg, directoryHash); } } diff --git a/src/gui/syncconflictsmodel.cpp b/src/gui/syncconflictsmodel.cpp index 2ddbf0225786d..d6a7e702bcad3 100644 --- a/src/gui/syncconflictsmodel.cpp +++ b/src/gui/syncconflictsmodel.cpp @@ -224,7 +224,7 @@ void SyncConflictsModel::selectAllConflicting(bool selected) void SyncConflictsModel::applySolution() { - for(const auto &syncConflict : qAsConst(_conflictData)) { + for(const auto &syncConflict : std::as_const(_conflictData)) { if (syncConflict.isValid()) { qCInfo(lcSyncConflictsModel) << syncConflict.mExistingFilePath << syncConflict.mConflictingFilePath << syncConflict.solution(); ConflictSolver solver; @@ -240,7 +240,7 @@ void SyncConflictsModel::updateConflictsData() _conflictData.clear(); _conflictData.reserve(_data.size()); - for (const auto &oneConflict : qAsConst(_data)) { + for (const auto &oneConflict : std::as_const(_data)) { const auto folder = FolderMan::instance()->folder(oneConflict._folder); if (!folder) { qCWarning(lcSyncConflictsModel) << "no Folder instance for" << oneConflict._folder; diff --git a/src/gui/tray/unifiedsearchresultslistmodel.cpp b/src/gui/tray/unifiedsearchresultslistmodel.cpp index 6ec9a7a2a6382..2f461683cb76b 100644 --- a/src/gui/tray/unifiedsearchresultslistmodel.cpp +++ b/src/gui/tray/unifiedsearchresultslistmodel.cpp @@ -503,7 +503,7 @@ void UnifiedSearchResultsListModel::startSearch() endResetModel(); } - for (const auto &provider : qAsConst(_providers)) { + for (const auto &provider : std::as_const(_providers)) { startSearchForProvider(provider._id); } } @@ -725,7 +725,7 @@ void UnifiedSearchResultsListModel::removeFetchMoreTrigger(const QString &provid void UnifiedSearchResultsListModel::disconnectAndClearSearchJobs() { - for (const auto &connection : qAsConst(_searchJobConnections)) { + for (const auto &connection : std::as_const(_searchJobConnections)) { if (connection) { QObject::disconnect(connection); } diff --git a/src/gui/tray/usermodel.cpp b/src/gui/tray/usermodel.cpp index 30b3d699f81ee..abddeaa102d65 100644 --- a/src/gui/tray/usermodel.cpp +++ b/src/gui/tray/usermodel.cpp @@ -236,7 +236,7 @@ void User::slotBuildNotificationDisplay(const ActivityList &list) return; } - for (const auto &activity : qAsConst(toNotifyList)) { + for (const auto &activity : std::as_const(toNotifyList)) { if (activity._objectType == QStringLiteral("chat")) { showDesktopTalkNotification(activity); } else { @@ -1308,7 +1308,7 @@ QString UserModel::currentUserServer() void UserModel::addUser(AccountStatePtr &user, const bool &isCurrent) { bool containsUser = false; - for (const auto &u : qAsConst(_users)) { + for (const auto &u : std::as_const(_users)) { if (u->account() == user->account()) { containsUser = true; continue; @@ -1424,7 +1424,7 @@ void UserModel::setCurrentUserId(const int id) const auto isCurrentUserChanged = !_users[id]->isCurrentUser(); if (isCurrentUserChanged) { - for (const auto user : qAsConst(_users)) { + for (const auto user : std::as_const(_users)) { user->setCurrentUser(false); } _users[id]->setCurrentUser(true); diff --git a/src/libsync/discovery.cpp b/src/libsync/discovery.cpp index e842f82540808..4d8f57dfbf3a3 100644 --- a/src/libsync/discovery.cpp +++ b/src/libsync/discovery.cpp @@ -1858,7 +1858,7 @@ bool ProcessDirectoryJob::checkPermissions(const OCC::SyncFileItemPtr &item) bool ProcessDirectoryJob::isAnyParentBeingRestored(const QString &file) const { - for (const auto &directoryNameToRestore : qAsConst(_discoveryData->_directoryNamesToRestoreOnPropagation)) { + for (const auto &directoryNameToRestore : std::as_const(_discoveryData->_directoryNamesToRestoreOnPropagation)) { if (file.startsWith(QString(directoryNameToRestore + QLatin1Char('/')))) { qCWarning(lcDisco) << "File" << file << " is within the tree that's being restored" << directoryNameToRestore; return true; diff --git a/src/libsync/owncloudpropagator.cpp b/src/libsync/owncloudpropagator.cpp index fc166ecce8e90..5e4c5fa250057 100644 --- a/src/libsync/owncloudpropagator.cpp +++ b/src/libsync/owncloudpropagator.cpp @@ -1236,7 +1236,7 @@ bool PropagatorCompositeJob::scheduleSelfOrChild() } // Ask all the running composite jobs if they have something new to schedule. - for (auto runningJob : qAsConst(_runningJobs)) { + for (auto runningJob : std::as_const(_runningJobs)) { ASSERT(runningJob->_state == Running); if (possiblyRunNextJob(runningJob)) { diff --git a/src/libsync/propagateuploadng.cpp b/src/libsync/propagateuploadng.cpp index 32e1192f3fa2f..e193e9561178d 100644 --- a/src/libsync/propagateuploadng.cpp +++ b/src/libsync/propagateuploadng.cpp @@ -185,7 +185,7 @@ void PropagateUploadFileNG::slotPropfindFinished() // Make sure that if there is a "hole" and then a few more chunks, on the server // we should remove the later chunks. Otherwise when we do dynamic chunk sizing, we may end up // with corruptions if there are too many chunks, or if we abort and there are still stale chunks. - for (const auto &serverChunk : qAsConst(_serverChunks)) { + for (const auto &serverChunk : std::as_const(_serverChunks)) { auto job = new DeleteJob(propagator()->account(), Utility::concatUrlPath(chunkUploadFolderUrl(), serverChunk.originalName), this); QObject::connect(job, &DeleteJob::finishedSignal, this, &PropagateUploadFileNG::slotDeleteJobFinished); _jobs.append(job); diff --git a/src/libsync/syncengine.cpp b/src/libsync/syncengine.cpp index c64b9219ca3cd..8d4915b488ead 100644 --- a/src/libsync/syncengine.cpp +++ b/src/libsync/syncengine.cpp @@ -292,7 +292,7 @@ void SyncEngine::conflictRecordMaintenance() // // This happens when the conflicts table is new or when conflict files // are downloaded but the server doesn't send conflict headers. - for (const auto &path : qAsConst(_seenConflictFiles)) { + for (const auto &path : std::as_const(_seenConflictFiles)) { ASSERT(Utility::isConflictFile(path)); auto bapath = path.toUtf8(); @@ -964,7 +964,7 @@ void SyncEngine::restoreOldFiles(SyncFileItemVector &syncItems) upload the client file. But we still downloaded the old file in a conflict file just in case */ - for (const auto &syncItem : qAsConst(syncItems)) { + for (const auto &syncItem : std::as_const(syncItems)) { if (syncItem->_direction != SyncFileItem::Down || syncItem->_isSelectiveSync) { continue; } @@ -1023,7 +1023,7 @@ void SyncEngine::finishSync() } if (_discoveryPhase && _discoveryPhase->_hasDownloadRemovedItems && _discoveryPhase->_hasUploadErrorItems) { - for (const auto &item : qAsConst(_syncItems)) { + for (const auto &item : std::as_const(_syncItems)) { if (item->_instruction == CSYNC_INSTRUCTION_ERROR && item->_direction == SyncFileItem::Up) { // item->_instruction = CSYNC_INSTRUCTION_IGNORE; } @@ -1103,7 +1103,7 @@ bool SyncEngine::handleMassDeletion() const auto allFilesDeleted = !_hasNoneFiles && _hasRemoveFile; auto deletionCounter = 0; - for (const auto &oneItem : qAsConst(_syncItems)) { + for (const auto &oneItem : std::as_const(_syncItems)) { if (oneItem->_instruction == CSYNC_INSTRUCTION_REMOVE) { if (oneItem->isDirectory()) { const auto result = _journal->listFilesInPath(oneItem->_file.toUtf8(), [&deletionCounter] (const auto &oneRecord) { @@ -1124,7 +1124,7 @@ bool SyncEngine::handleMassDeletion() if ((allFilesDeleted || filesDeletedThresholdExceeded) && displayDialog) { qCWarning(lcEngine) << "Many files are going to be deleted, asking the user"; int side = 0; // > 0 means more deleted on the server. < 0 means more deleted on the client - for (const auto &it : qAsConst(_syncItems)) { + for (const auto &it : std::as_const(_syncItems)) { if (it->_instruction == CSYNC_INSTRUCTION_REMOVE) { side += it->_direction == SyncFileItem::Down ? 1 : -1; } @@ -1455,7 +1455,7 @@ void SyncEngine::slotScheduleFilesDelayedSync() newTimer->callOnTimeout(this, [this, newTimer] { qCInfo(lcEngine) << "Rescanning now that delayed sync run is scheduled for:" << newTimer->files; - for (const auto &file : qAsConst(newTimer->files)) { + for (const auto &file : std::as_const(newTimer->files)) { this->_filesScheduledForLaterSync.remove(file); } @@ -1586,7 +1586,7 @@ void SyncEngine::slotUnscheduleFilesDelayedSync() return; } - for (const auto &file : qAsConst(_discoveryPhase->_filesUnscheduleSync)) { + for (const auto &file : std::as_const(_discoveryPhase->_filesUnscheduleSync)) { const auto fileSyncRunTimer = _filesScheduledForLaterSync.value(file); if (fileSyncRunTimer) { diff --git a/src/libsync/syncfilestatustracker.cpp b/src/libsync/syncfilestatustracker.cpp index 2b934806fa08c..6e4e809629b4f 100644 --- a/src/libsync/syncfilestatustracker.cpp +++ b/src/libsync/syncfilestatustracker.cpp @@ -268,7 +268,7 @@ void SyncFileStatusTracker::slotAboutToPropagate(SyncFileItemVector &items) // Swap into a copy since fileStatus() reads _dirtyPaths to determine the status QSet oldDirtyPaths; std::swap(_dirtyPaths, oldDirtyPaths); - for (const auto &oldDirtyPath : qAsConst(oldDirtyPaths)) + for (const auto &oldDirtyPath : std::as_const(oldDirtyPaths)) emit fileStatusChanged(getSystemDestination(oldDirtyPath), fileStatus(oldDirtyPath)); // Make sure to push any status that might have been resolved indirectly since the last sync diff --git a/src/libsync/vfs/cfapi/cfapiwrapper.cpp b/src/libsync/vfs/cfapi/cfapiwrapper.cpp index c1d13479f69e5..98beaacffb39b 100644 --- a/src/libsync/vfs/cfapi/cfapiwrapper.cpp +++ b/src/libsync/vfs/cfapi/cfapiwrapper.cpp @@ -591,7 +591,7 @@ bool createSyncRootRegistryKeys(const QString &providerName, const QString &fold { providerSyncRootIdRegistryKey, QStringLiteral("NamespaceCLSID"), REG_SZ, QString(navigationPaneClsid)} }; - for (const auto ®istryKeyToSet : qAsConst(registryKeysToSet)) { + for (const auto ®istryKeyToSet : std::as_const(registryKeysToSet)) { if (!OCC::Utility::registrySetKeyValue(HKEY_LOCAL_MACHINE, registryKeyToSet.subKey, registryKeyToSet.valueName, registryKeyToSet.type, registryKeyToSet.value)) { qCWarning(lcCfApiWrapper) << "Failed to set Registry keys for shell integration. Progress bar will not work."; const auto deleteKeyResult = OCC::Utility::registryDeleteKeyTree(HKEY_LOCAL_MACHINE, providerSyncRootIdRegistryKey); From 24933ebb644f54d433d186d7e2c15811d589344f Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Thu, 28 Nov 2024 17:04:50 +0800 Subject: [PATCH 02/22] Ensure use of QMessageBox-using QMessageBox::critical Fixes deprecation warnings Signed-off-by: Claudio Cambra f ensure qmessagebox Signed-off-by: Claudio Cambra f2 ensure qm Signed-off-by: Claudio Cambra f3 Signed-off-by: Claudio Cambra f4 Signed-off-by: Claudio Cambra --- src/gui/application.cpp | 3 ++- src/gui/editlocallymanager.cpp | 2 +- src/gui/foldercreationdialog.cpp | 2 +- src/gui/generalsettings.cpp | 3 ++- src/gui/main.cpp | 8 ++++++-- src/gui/socketapi/socketapi.cpp | 22 ++++++++++++++-------- 6 files changed, 26 insertions(+), 14 deletions(-) diff --git a/src/gui/application.cpp b/src/gui/application.cpp index dcac6ad3234fc..0aaeffd79eae6 100644 --- a/src/gui/application.cpp +++ b/src/gui/application.cpp @@ -588,7 +588,8 @@ AccountManager::AccountsRestoreResult Application::restoreLegacyAccount() tr("There was an error while accessing the configuration " "file at %1. Please make sure the file can be accessed by your system account.") .arg(ConfigFile().configFile()), - tr("Quit %1").arg(Theme::instance()->appNameGUI())); + QMessageBox::Ok + ); QTimer::singleShot(0, qApp, &QCoreApplication::quit); } } diff --git a/src/gui/editlocallymanager.cpp b/src/gui/editlocallymanager.cpp index 59c25e830b03b..e2c3d3c7ecf5f 100644 --- a/src/gui/editlocallymanager.cpp +++ b/src/gui/editlocallymanager.cpp @@ -52,7 +52,7 @@ void EditLocallyManager::showError(const QString &message, const QString &inform void EditLocallyManager::showErrorNotification(const QString &message, const QString &informativeText) { - Systray::instance()->showMessage(message, informativeText, Systray::MessageIcon::Critical); + Systray::instance()->showMessage(message, informativeText, Systray::MessageIcon::Critical); } void EditLocallyManager::showErrorMessageBox(const QString &message, diff --git a/src/gui/foldercreationdialog.cpp b/src/gui/foldercreationdialog.cpp index a245c9f4dc461..302bc041282bc 100644 --- a/src/gui/foldercreationdialog.cpp +++ b/src/gui/foldercreationdialog.cpp @@ -77,7 +77,7 @@ void FolderCreationDialog::accept() if (QDir(_destination).mkdir(ui->newFolderNameEdit->text())) { Q_EMIT folderCreated(fullPath); } else { - QMessageBox::critical(this, tr("Error"), tr("Could not create a folder! Check your write permissions.")); + QMessageBox::critical(this, tr("Error"), tr("Could not create a folder! Check your write permissions."), QMessageBox::Ok); } QDialog::accept(); diff --git a/src/gui/generalsettings.cpp b/src/gui/generalsettings.cpp index 562e41642ccfe..843be0dd568b6 100644 --- a/src/gui/generalsettings.cpp +++ b/src/gui/generalsettings.cpp @@ -129,7 +129,8 @@ bool createDebugArchive(const QString &filename) QMessageBox::critical( nullptr, QObject::tr("Failed to create debug archive"), - QObject::tr("Could not create debug archive in selected location!") + QObject::tr("Could not create debug archive in selected location!"), + QMessageBox::Ok ); return false; } diff --git a/src/gui/main.cpp b/src/gui/main.cpp index da946bc3b32c0..b603a8a7c0b14 100644 --- a/src/gui/main.cpp +++ b/src/gui/main.cpp @@ -45,12 +45,16 @@ using namespace OCC; void warnSystray() { - QMessageBox::critical(nullptr, qApp->translate("main.cpp", "System Tray not available"), + QMessageBox::critical( + nullptr, + qApp->translate("main.cpp", "System Tray not available"), qApp->translate("main.cpp", "%1 requires on a working system tray. " "If you are running XFCE, please follow " "these instructions. " "Otherwise, please install a system tray application such as \"trayer\" and try again.") - .arg(Theme::instance()->appNameGUI())); + .arg(Theme::instance()->appNameGUI()), + QMessageBox::Ok + ); } int main(int argc, char **argv) diff --git a/src/gui/socketapi/socketapi.cpp b/src/gui/socketapi/socketapi.cpp index cf47d3f5bcd5e..a3df567ee1fe5 100644 --- a/src/gui/socketapi/socketapi.cpp +++ b/src/gui/socketapi/socketapi.cpp @@ -546,10 +546,13 @@ void SocketApi::processEncryptRequest(const QString &localFile) Q_ASSERT(rec.isValid()); if (!account->e2e() || account->e2e()->_mnemonic.isEmpty()) { - const int ret = QMessageBox::critical(nullptr, - tr("Failed to encrypt folder at \"%1\"").arg(fileData.folderRelativePath), - tr("The account %1 does not have end-to-end encryption configured. " - "Please configure this in your account settings to enable folder encryption.").arg(account->prettyName())); + const int ret = QMessageBox::critical( + nullptr, + tr("Failed to encrypt folder at \"%1\"").arg(fileData.folderRelativePath), + tr("The account %1 does not have end-to-end encryption configured. " + "Please configure this in your account settings to enable folder encryption.").arg(account->prettyName()), + QMessageBox::Ok + ); Q_UNUSED(ret) return; } @@ -563,10 +566,13 @@ void SocketApi::processEncryptRequest(const QString &localFile) job->setParent(this); connect(job, &OCC::EncryptFolderJob::finished, this, [fileData, job](const int status) { if (status == OCC::EncryptFolderJob::Error) { - const int ret = QMessageBox::critical(nullptr, - tr("Failed to encrypt folder"), - tr("Could not encrypt the following folder: \"%1\".\n\n" - "Server replied with error: %2").arg(fileData.folderRelativePath, job->errorString())); + const int ret = QMessageBox::critical( + nullptr, + tr("Failed to encrypt folder"), + tr("Could not encrypt the following folder: \"%1\".\n\n" + "Server replied with error: %2").arg(fileData.folderRelativePath, job->errorString()), + QMessageBox::Ok + ); Q_UNUSED(ret) } else { const int ret = QMessageBox::information(nullptr, From d978b1f4f592dc739ee3d5999da4a10c85545218 Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Thu, 28 Nov 2024 17:10:54 +0800 Subject: [PATCH 03/22] Replace use of deprecated QLibraryInfo::location with QLibraryInfo::path Signed-off-by: Claudio Cambra --- src/gui/application.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/application.cpp b/src/gui/application.cpp index 0aaeffd79eae6..ab4d4159ee5fb 100644 --- a/src/gui/application.cpp +++ b/src/gui/application.cpp @@ -1003,7 +1003,7 @@ void Application::setupTranslations() // have a translation file provided. qCInfo(lcApplication) << "Using" << lang << "translation"; setProperty("ui_lang", lang); - const QString qtTrPath = QLibraryInfo::location(QLibraryInfo::TranslationsPath); + const QString qtTrPath = QLibraryInfo::path(QLibraryInfo::TranslationsPath); const QString qtTrFile = QLatin1String("qt_") + lang; const QString qtBaseTrFile = QLatin1String("qtbase_") + lang; if (!qtTranslator->load(qtTrFile, qtTrPath)) { From 58971d538ad18447b9a3056dbee53a170532b5a7 Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Thu, 28 Nov 2024 17:12:09 +0800 Subject: [PATCH 04/22] Replace use of itemDelegate with itemDelegateForIndex Signed-off-by: Claudio Cambra --- src/gui/accountsettings.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/accountsettings.cpp b/src/gui/accountsettings.cpp index bc5bda41d1dec..47c8793794a4d 100644 --- a/src/gui/accountsettings.cpp +++ b/src/gui/accountsettings.cpp @@ -735,7 +735,7 @@ void AccountSettings::slotFolderListClicked(const QModelIndex &indx) QStyleOptionViewItem opt; opt.initFrom(treeView); const auto btnRect = treeView->visualRect(indx); - const auto btnSize = treeView->itemDelegate(indx)->sizeHint(opt, indx); + const auto btnSize = treeView->itemDelegateForIndex(indx)->sizeHint(opt, indx); const auto actual = QStyle::visualRect(opt.direction, btnRect, QRect(btnRect.topLeft(), btnSize)); if (!actual.contains(pos)) { return; From ec1ac85fc3bb408cfe88117c5498c1dee41d775a Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Thu, 28 Nov 2024 17:17:22 +0800 Subject: [PATCH 05/22] Replace use of QCheckBox::stateChanged with QCheckBox::checkStateChanged Signed-off-by: Claudio Cambra --- src/gui/folderwizard.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/folderwizard.cpp b/src/gui/folderwizard.cpp index 8cf29f35e43c9..6a45da8a15aed 100644 --- a/src/gui/folderwizard.cpp +++ b/src/gui/folderwizard.cpp @@ -570,7 +570,7 @@ FolderWizardSelectiveSync::FolderWizardSelectiveSync(const AccountPtr &account) if (Theme::instance()->showVirtualFilesOption() && bestAvailableVfsMode() != Vfs::Off) { _virtualFilesCheckBox = new QCheckBox(tr("Use virtual files instead of downloading content immediately %1").arg(bestAvailableVfsMode() == Vfs::WindowsCfApi ? QString() : tr("(experimental)"))); connect(_virtualFilesCheckBox, &QCheckBox::clicked, this, &FolderWizardSelectiveSync::virtualFilesCheckboxClicked); - connect(_virtualFilesCheckBox, &QCheckBox::stateChanged, this, [this](int state) { + connect(_virtualFilesCheckBox, &QCheckBox::checkStateChanged, this, [this](int state) { _selectiveSync->setEnabled(state == Qt::Unchecked); }); _virtualFilesCheckBox->setChecked(bestAvailableVfsMode() == Vfs::WindowsCfApi); From 9d86dbb13eb942bb58e688af3080fbf3ab934e05 Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Thu, 28 Nov 2024 17:33:43 +0800 Subject: [PATCH 06/22] Use QTimeZone::UTC instead of Qt::UTC Signed-off-by: Claudio Cambra f qtimezone Signed-off-by: Claudio Cambra --- src/gui/sslerrordialog.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/sslerrordialog.cpp b/src/gui/sslerrordialog.cpp index bd3eee0b434b9..b8c65e556c530 100644 --- a/src/gui/sslerrordialog.cpp +++ b/src/gui/sslerrordialog.cpp @@ -201,7 +201,7 @@ QString SslErrorDialog::certDiv(QSslCertificate cert) const msg += QL("

"); - if (cert.effectiveDate() < QDateTime(QDate(2016, 1, 1), QTime(), Qt::UTC)) { + if (cert.effectiveDate() < QDateTime(QDate(2016, 1, 1), QTime(), QTimeZone::UTC)) { QString sha1sum = Utility::formatFingerprint(cert.digest(QCryptographicHash::Sha1).toHex()); msg += tr("Fingerprint (SHA1): %1").arg(sha1sum) + QL("
"); } From 313a8a38a1899d920735220e3b3b37b500e33b8d Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Thu, 28 Nov 2024 17:35:34 +0800 Subject: [PATCH 07/22] Remove unneeded take from systray Signed-off-by: Claudio Cambra --- src/gui/systray.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/gui/systray.cpp b/src/gui/systray.cpp index 85fee594c9f7b..8074a4b7977b7 100644 --- a/src/gui/systray.cpp +++ b/src/gui/systray.cpp @@ -314,7 +314,6 @@ void Systray::createResolveConflictsDialog(const OCC::ActivityList &allConflicts dialogWindow->show(); dialogWindow->raise(); dialogWindow->requestActivate(); - dialog.take(); } bool Systray::raiseDialogs() From bacdf9916e13bc1104802ba08dc75d08756ed906 Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Thu, 28 Nov 2024 17:41:55 +0800 Subject: [PATCH 08/22] Do not use const char * to add data to crypto hash method is deprecated Signed-off-by: Claudio Cambra fix qbyte Signed-off-by: Claudio Cambra --- src/common/checksumcalculator.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common/checksumcalculator.cpp b/src/common/checksumcalculator.cpp index ec9faa2de8c5a..acd19d4c6cb77 100644 --- a/src/common/checksumcalculator.cpp +++ b/src/common/checksumcalculator.cpp @@ -170,7 +170,7 @@ bool ChecksumCalculator::addChunk(const QByteArray &chunk, const qint64 size) } else { Q_ASSERT(_cryptographicHash); if (_cryptographicHash) { - _cryptographicHash->addData(chunk.data(), size); + _cryptographicHash->addData(chunk); return true; } } From 2a2a8161448d6f0ee6f0e882ba062e61f7498a2d Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Thu, 28 Nov 2024 17:44:50 +0800 Subject: [PATCH 09/22] Replace deprecated QVariant types with QMetaType Signed-off-by: Claudio Cambra Use QVariant metaType instead of type Signed-off-by: Claudio Cambra f metatype Signed-off-by: Claudio Cambra --- src/common/ownsql.cpp | 34 +++++++++------------------------- src/libsync/foldermetadata.cpp | 6 +++--- 2 files changed, 12 insertions(+), 28 deletions(-) diff --git a/src/common/ownsql.cpp b/src/common/ownsql.cpp index 7b4fbd225dcfc..3577f489479c9 100644 --- a/src/common/ownsql.cpp +++ b/src/common/ownsql.cpp @@ -364,34 +364,24 @@ void SqlQuery::bindValueInternal(int pos, const QVariant &value) return; } - switch (value.type()) { - case QVariant::Int: - case QVariant::Bool: + const auto metatype = value.metaType(); + if (metatype == QMetaType(QMetaType::Int) || metatype == QMetaType(QMetaType::Bool)) { res = sqlite3_bind_int(_stmt, pos, value.toInt()); - break; - case QVariant::Double: + } else if (metatype == QMetaType(QMetaType::Double)) { res = sqlite3_bind_double(_stmt, pos, value.toDouble()); - break; - case QVariant::UInt: - case QVariant::LongLong: - case QVariant::ULongLong: + } else if (metatype == QMetaType(QMetaType::UInt) || metatype == QMetaType(QMetaType::LongLong) || metatype == QMetaType(QMetaType::ULongLong)) { res = sqlite3_bind_int64(_stmt, pos, value.toLongLong()); - break; - case QVariant::DateTime: { + } else if (metatype == QMetaType(QMetaType::QDateTime)) { const QDateTime dateTime = value.toDateTime(); const QString str = dateTime.toString(QStringLiteral("yyyy-MM-ddThh:mm:ss.zzz")); res = sqlite3_bind_text16(_stmt, pos, str.utf16(), str.size() * static_cast(sizeof(ushort)), SQLITE_TRANSIENT); - break; - } - case QVariant::Time: { + } else if (metatype == QMetaType(QMetaType::QTime)) { const QTime time = value.toTime(); const QString str = time.toString(QStringLiteral("hh:mm:ss.zzz")); res = sqlite3_bind_text16(_stmt, pos, str.utf16(), str.size() * static_cast(sizeof(ushort)), SQLITE_TRANSIENT); - break; - } - case QVariant::String: { + } else if (metatype == QMetaType(QMetaType::QString)) { if (!value.toString().isNull()) { // lifetime of string == lifetime of its qvariant const auto *str = static_cast(value.constData()); @@ -400,20 +390,14 @@ void SqlQuery::bindValueInternal(int pos, const QVariant &value) } else { res = sqlite3_bind_null(_stmt, pos); } - break; - } - case QVariant::ByteArray: { + } else if (metatype == QMetaType(QMetaType::QByteArray)) { auto ba = value.toByteArray(); res = sqlite3_bind_text(_stmt, pos, ba.constData(), ba.size(), SQLITE_TRANSIENT); - break; - } - default: { + } else { QString str = value.toString(); // SQLITE_TRANSIENT makes sure that sqlite buffers the data res = sqlite3_bind_text16(_stmt, pos, str.utf16(), (str.size()) * static_cast(sizeof(QChar)), SQLITE_TRANSIENT); - break; - } } if (res != SQLITE_OK) { qCWarning(lcSql) << "ERROR binding SQL value:" << value << "error:" << res; diff --git a/src/libsync/foldermetadata.cpp b/src/libsync/foldermetadata.cpp index f3a21953d341d..38ace714d0f69 100644 --- a/src/libsync/foldermetadata.cpp +++ b/src/libsync/foldermetadata.cpp @@ -400,11 +400,11 @@ void FolderMetadata::setupVersionFromExistingMetadata(const QByteArray &metadata } else if (metaDataDoc.object().contains(versionKey)) { const auto metadataVersionValue = metaDataDoc.object()[versionKey].toVariant(); - if (metadataVersionValue.type() == QVariant::Type::String) { + if (metadataVersionValue.metaType() == QMetaType(QMetaType::QString)) { versionStringFromMetadata = metadataVersionValue.toString(); - } else if (metadataVersionValue.type() == QVariant::Type::Double) { + } else if (metadataVersionValue.metaType() == QMetaType(QMetaType::Double)) { versionStringFromMetadata = QString::number(metadataVersionValue.toDouble(), 'f', 1); - } else if (metadataVersionValue.type() == QVariant::Type::Int) { + } else if (metadataVersionValue.metaType() == QMetaType(QMetaType::Int)) { versionStringFromMetadata = QString::number(metadataVersionValue.toInt()) + QStringLiteral(".0"); } } From dabe041ef280827e88e34268f2aaf1249061c3c1 Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Thu, 28 Nov 2024 17:53:02 +0800 Subject: [PATCH 10/22] Use char16_t cast instead of ushort cast Fix deprecation warning Signed-off-by: Claudio Cambra --- src/common/ownsql.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common/ownsql.cpp b/src/common/ownsql.cpp index 3577f489479c9..79e097b452911 100644 --- a/src/common/ownsql.cpp +++ b/src/common/ownsql.cpp @@ -412,7 +412,7 @@ bool SqlQuery::nullValue(int index) QString SqlQuery::stringValue(int index) { - return QString::fromUtf16(static_cast(sqlite3_column_text16(_stmt, index))); + return QString::fromUtf16(static_cast(sqlite3_column_text16(_stmt, index))); } int SqlQuery::intValue(int index) From 25ac0b6f147c29caacbf24f88f5edcc93625e717 Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Thu, 28 Nov 2024 17:53:24 +0800 Subject: [PATCH 11/22] Use unique_ptr over scoped pointer take is deprecated in scoped pointer Signed-off-by: Claudio Cambra f handle Signed-off-by: Claudio Cambra Use unique_ptr instead of scoped pointer for propagator firstJob Fixes deprecation warning Signed-off-by: Claudio Cambra Use unique_ptr for discoveryphase, replace take with release Fix deprecation warn Signed-off-by: Claudio Cambra f unique Signed-off-by: Claudio Cambra --- src/csync/vio/csync_vio_local_unix.cpp | 5 ++-- src/gui/wizard/flow2authwidget.cpp | 15 ++++++------ src/gui/wizard/flow2authwidget.h | 2 +- src/libsync/owncloudpropagator.cpp | 4 ++-- src/libsync/owncloudpropagator.h | 2 +- src/libsync/syncengine.cpp | 32 +++++++++++++------------- src/libsync/syncengine.h | 2 +- 7 files changed, 31 insertions(+), 31 deletions(-) diff --git a/src/csync/vio/csync_vio_local_unix.cpp b/src/csync/vio/csync_vio_local_unix.cpp index ec47ab3c7c994..8f319a3e4b23f 100644 --- a/src/csync/vio/csync_vio_local_unix.cpp +++ b/src/csync/vio/csync_vio_local_unix.cpp @@ -52,8 +52,7 @@ struct csync_vio_handle_t { static int _csync_vio_local_stat_mb(const mbchar_t *wuri, csync_file_stat_t *buf); csync_vio_handle_t *csync_vio_local_opendir(const QString &name) { - QScopedPointer handle(new csync_vio_handle_t{}); - + auto handle = std::make_unique(); auto dirname = QFile::encodeName(name); handle->dh = _topendir(dirname.constData()); @@ -62,7 +61,7 @@ csync_vio_handle_t *csync_vio_local_opendir(const QString &name) { } handle->path = dirname; - return handle.take(); + return handle.release(); } int csync_vio_local_closedir(csync_vio_handle_t *dhandle) { diff --git a/src/gui/wizard/flow2authwidget.cpp b/src/gui/wizard/flow2authwidget.cpp index 87f63d59197a8..cb9262846d971 100644 --- a/src/gui/wizard/flow2authwidget.cpp +++ b/src/gui/wizard/flow2authwidget.cpp @@ -65,19 +65,20 @@ void Flow2AuthWidget::setLogo() void Flow2AuthWidget::startAuth(Account *account) { - Flow2Auth *oldAuth = _asyncAuth.take(); - if(oldAuth) + const auto oldAuth = _asyncAuth.release(); + if (oldAuth) { oldAuth->deleteLater(); + } _statusUpdateSkipCount = 0; if(account) { _account = account; - _asyncAuth.reset(new Flow2Auth(_account, this)); - connect(_asyncAuth.data(), &Flow2Auth::result, this, &Flow2AuthWidget::slotAuthResult, Qt::QueuedConnection); - connect(_asyncAuth.data(), &Flow2Auth::statusChanged, this, &Flow2AuthWidget::slotStatusChanged); - connect(this, &Flow2AuthWidget::pollNow, _asyncAuth.data(), &Flow2Auth::slotPollNow); + _asyncAuth = std::make_unique(_account, this); + connect(_asyncAuth.get(), &Flow2Auth::result, this, &Flow2AuthWidget::slotAuthResult, Qt::QueuedConnection); + connect(_asyncAuth.get(), &Flow2Auth::statusChanged, this, &Flow2AuthWidget::slotStatusChanged); + connect(this, &Flow2AuthWidget::pollNow, _asyncAuth.get(), &Flow2Auth::slotPollNow); _asyncAuth->start(); } } @@ -122,7 +123,7 @@ void Flow2AuthWidget::setError(const QString &error) { Flow2AuthWidget::~Flow2AuthWidget() { // Forget sensitive data - _asyncAuth.reset(); + _asyncAuth.reset(nullptr); } void Flow2AuthWidget::slotOpenBrowser() diff --git a/src/gui/wizard/flow2authwidget.h b/src/gui/wizard/flow2authwidget.h index 2660ff0b76209..4c622fab343ea 100644 --- a/src/gui/wizard/flow2authwidget.h +++ b/src/gui/wizard/flow2authwidget.h @@ -49,7 +49,7 @@ public Q_SLOTS: private: Account *_account = nullptr; - QScopedPointer _asyncAuth; + std::unique_ptr _asyncAuth; Ui_Flow2AuthWidget _ui{}; protected Q_SLOTS: diff --git a/src/libsync/owncloudpropagator.cpp b/src/libsync/owncloudpropagator.cpp index 5e4c5fa250057..dac9a0e608cbe 100644 --- a/src/libsync/owncloudpropagator.cpp +++ b/src/libsync/owncloudpropagator.cpp @@ -1352,7 +1352,7 @@ PropagateDirectory::PropagateDirectory(OwncloudPropagator *propagator, const Syn , _subJobs(propagator) { if (_firstJob) { - connect(_firstJob.data(), &PropagatorJob::finished, this, &PropagateDirectory::slotFirstJobFinished); + connect(_firstJob.get(), &PropagatorJob::finished, this, &PropagateDirectory::slotFirstJobFinished); _firstJob->setAssociatedComposite(&_subJobs); } connect(&_subJobs, &PropagatorJob::finished, this, &PropagateDirectory::slotSubJobsFinished); @@ -1395,7 +1395,7 @@ bool PropagateDirectory::scheduleSelfOrChild() void PropagateDirectory::slotFirstJobFinished(SyncFileItem::Status status) { - _firstJob.take()->deleteLater(); + _firstJob.release()->deleteLater(); if (status != SyncFileItem::Success && status != SyncFileItem::Restoration diff --git a/src/libsync/owncloudpropagator.h b/src/libsync/owncloudpropagator.h index 1a96ece644c5d..ad19111118423 100644 --- a/src/libsync/owncloudpropagator.h +++ b/src/libsync/owncloudpropagator.h @@ -315,7 +315,7 @@ class OWNCLOUDSYNC_EXPORT PropagateDirectory : public PropagatorJob public: SyncFileItemPtr _item; // e.g: create the directory - QScopedPointer _firstJob; + std::unique_ptr _firstJob; PropagatorCompositeJob _subJobs; diff --git a/src/libsync/syncengine.cpp b/src/libsync/syncengine.cpp index 8d4915b488ead..f691ce09da3a8 100644 --- a/src/libsync/syncengine.cpp +++ b/src/libsync/syncengine.cpp @@ -637,7 +637,7 @@ void SyncEngine::startSync() _remnantReadOnlyFolders.clear(); - _discoveryPhase.reset(new DiscoveryPhase); + _discoveryPhase = std::make_unique(); _discoveryPhase->_leadingAndTrailingSpacesFilesAllowed = _leadingAndTrailingSpacesFilesAllowed; _discoveryPhase->_account = _account; _discoveryPhase->_excludes = _excludedFiles.data(); @@ -679,17 +679,17 @@ void SyncEngine::startSync() _discoveryPhase->_serverBlacklistedFiles = _account->capabilities().blacklistedFiles(); _discoveryPhase->_ignoreHiddenFiles = ignoreHiddenFiles(); - connect(_discoveryPhase.data(), &DiscoveryPhase::itemDiscovered, this, &SyncEngine::slotItemDiscovered); - connect(_discoveryPhase.data(), &DiscoveryPhase::newBigFolder, this, &SyncEngine::newBigFolder); - connect(_discoveryPhase.data(), &DiscoveryPhase::existingFolderNowBig, this, &SyncEngine::existingFolderNowBig); - connect(_discoveryPhase.data(), &DiscoveryPhase::fatalError, this, [this](const QString &errorString, ErrorCategory errorCategory) { + connect(_discoveryPhase.get(), &DiscoveryPhase::itemDiscovered, this, &SyncEngine::slotItemDiscovered); + connect(_discoveryPhase.get(), &DiscoveryPhase::newBigFolder, this, &SyncEngine::newBigFolder); + connect(_discoveryPhase.get(), &DiscoveryPhase::existingFolderNowBig, this, &SyncEngine::existingFolderNowBig); + connect(_discoveryPhase.get(), &DiscoveryPhase::fatalError, this, [this](const QString &errorString, ErrorCategory errorCategory) { Q_EMIT syncError(errorString, errorCategory); finalize(false); }); - connect(_discoveryPhase.data(), &DiscoveryPhase::finished, this, &SyncEngine::slotDiscoveryFinished); - connect(_discoveryPhase.data(), &DiscoveryPhase::silentlyExcluded, + connect(_discoveryPhase.get(), &DiscoveryPhase::finished, this, &SyncEngine::slotDiscoveryFinished); + connect(_discoveryPhase.get(), &DiscoveryPhase::silentlyExcluded, _syncFileStatusTracker.data(), &SyncFileStatusTracker::slotAddSilentlyExcluded); - connect(_discoveryPhase.data(), &DiscoveryPhase::remnantReadOnlyFolderDiscovered, this, &SyncEngine::remnantReadOnlyFolderDiscovered); + connect(_discoveryPhase.get(), &DiscoveryPhase::remnantReadOnlyFolderDiscovered, this, &SyncEngine::remnantReadOnlyFolderDiscovered); ProcessDirectoryJob *discoveryJob = nullptr; @@ -724,27 +724,27 @@ void SyncEngine::startSync() }(); discoveryJob = new ProcessDirectoryJob( - _discoveryPhase.data(), + _discoveryPhase.get(), pinState, path, singleItemDiscoveryOptions().discoveryDirItem, {}, localQueryMode, _journal->keyValueStoreGetInt("last_sync", 0), - _discoveryPhase.data() + _discoveryPhase.get() ); } else { discoveryJob = new ProcessDirectoryJob( - _discoveryPhase.data(), + _discoveryPhase.get(), PinState::AlwaysLocal, _journal->keyValueStoreGetInt("last_sync", 0), - _discoveryPhase.data() + _discoveryPhase.get() ); } _discoveryPhase->startJob(discoveryJob); connect(discoveryJob, &ProcessDirectoryJob::etag, this, &SyncEngine::slotRootEtagReceived); - connect(_discoveryPhase.data(), &DiscoveryPhase::addErrorToGui, this, &SyncEngine::addErrorToGui); + connect(_discoveryPhase.get(), &DiscoveryPhase::addErrorToGui, this, &SyncEngine::addErrorToGui); } void SyncEngine::slotFolderDiscovered(bool local, const QString &folder) @@ -910,7 +910,7 @@ void SyncEngine::finalize(bool success) _stopWatch.stop(); if (_discoveryPhase) { - _discoveryPhase.take()->deleteLater(); + _discoveryPhase.release()->deleteLater(); } s_anySyncRunning = false; _syncRunning = false; @@ -1369,8 +1369,8 @@ void SyncEngine::abort() } else if (_discoveryPhase) { // Delete the discovery and all child jobs after ensuring // it can't finish and start the propagator - disconnect(_discoveryPhase.data(), nullptr, this, nullptr); - _discoveryPhase.take()->deleteLater(); + disconnect(_discoveryPhase.get(), nullptr, this, nullptr); + _discoveryPhase.release()->deleteLater(); qCInfo(lcEngine) << "Aborting sync in discovery..."; finalize(false); } diff --git a/src/libsync/syncengine.h b/src/libsync/syncengine.h index 63ab0a787e218..2dc5bfa6b4a32 100644 --- a/src/libsync/syncengine.h +++ b/src/libsync/syncengine.h @@ -339,7 +339,7 @@ private slots: QString _remotePath; QByteArray _remoteRootEtag; SyncJournalDb *_journal; - QScopedPointer _discoveryPhase; + std::unique_ptr _discoveryPhase; QSharedPointer _propagator; QSet _bulkUploadBlackList; From 6fc2d3bf39ba40597e448f848e16372dfd825e4d Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Thu, 28 Nov 2024 17:53:43 +0800 Subject: [PATCH 12/22] Use matchView instead of match match is deprecated Signed-off-by: Claudio Cambra --- src/csync/csync_exclude.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/csync/csync_exclude.cpp b/src/csync/csync_exclude.cpp index 5d0b462bd4697..2c23656f2320f 100644 --- a/src/csync/csync_exclude.cpp +++ b/src/csync/csync_exclude.cpp @@ -461,10 +461,10 @@ CSYNC_EXCLUDE_TYPE ExcludedFiles::traversalPatternMatch(const QString &path, Ite QRegularExpressionMatch m; if (filetype == ItemTypeDirectory && _bnameTraversalRegexDir.contains(basePath)) { - m = _bnameTraversalRegexDir[basePath].match(bnameStr); + m = _bnameTraversalRegexDir[basePath].matchView(bnameStr); } else if (filetype == ItemTypeFile && _bnameTraversalRegexFile.contains(basePath)) { - m = _bnameTraversalRegexFile[basePath].match(bnameStr); + m = _bnameTraversalRegexFile[basePath].matchView(bnameStr); } else { continue; } From 72e7825c25f714ba23f50c8501e91eb5247859c6 Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Thu, 28 Nov 2024 17:58:23 +0800 Subject: [PATCH 13/22] Use std::prev ove -1ing the iterator Signed-off-by: Claudio Cambra Use std::prev for it rather than -1 in Syncengine Signed-off-by: Claudio Cambra --- src/libsync/discovery.cpp | 2 +- src/libsync/syncengine.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/libsync/discovery.cpp b/src/libsync/discovery.cpp index 4d8f57dfbf3a3..927a248da67b0 100644 --- a/src/libsync/discovery.cpp +++ b/src/libsync/discovery.cpp @@ -1824,7 +1824,7 @@ bool ProcessDirectoryJob::checkPermissions(const OCC::SyncFileItemPtr &item) QString fileSlash = item->_file + '/'; auto forbiddenIt = _discoveryData->_forbiddenDeletes.upperBound(fileSlash); if (forbiddenIt != _discoveryData->_forbiddenDeletes.begin()) - forbiddenIt -= 1; + forbiddenIt = std::prev(forbiddenIt); if (forbiddenIt != _discoveryData->_forbiddenDeletes.end() && fileSlash.startsWith(forbiddenIt.key())) { item->_instruction = CSYNC_INSTRUCTION_NEW; diff --git a/src/libsync/syncengine.cpp b/src/libsync/syncengine.cpp index f691ce09da3a8..368d0f8c899bd 100644 --- a/src/libsync/syncengine.cpp +++ b/src/libsync/syncengine.cpp @@ -1205,8 +1205,8 @@ bool SyncEngine::wasFileTouched(const QString &fn) const // Start from the end (most recent) and look for our path. Check the time just in case. auto begin = _touchedFiles.constBegin(); for (auto it = _touchedFiles.constEnd(); it != begin; --it) { - if ((it-1).value() == fn) - return std::chrono::milliseconds((it-1).key().elapsed()) <= s_touchedFilesMaxAgeMs; + if (const auto prevIt = std::prev(it); prevIt.value() == fn) + return std::chrono::milliseconds(prevIt.key().elapsed()) <= s_touchedFilesMaxAgeMs; } return false; } From 0f1196474aa655fbd0c6e7bc4c729a37e23f8326 Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Thu, 28 Nov 2024 17:58:41 +0800 Subject: [PATCH 14/22] Replace QWebSocket::error with errorOccurred Signed-off-by: Claudio Cambra --- src/libsync/pushnotifications.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/libsync/pushnotifications.cpp b/src/libsync/pushnotifications.cpp index 89ca8221b75a8..6bfad9d62a535 100644 --- a/src/libsync/pushnotifications.cpp +++ b/src/libsync/pushnotifications.cpp @@ -30,7 +30,7 @@ PushNotifications::PushNotifications(Account *account, QObject *parent) , _account(account) , _webSocket(new QWebSocket(QString(), QWebSocketProtocol::VersionLatest, this)) { - connect(_webSocket, QOverload::of(&QWebSocket::error), this, &PushNotifications::onWebSocketError); + connect(_webSocket, QOverload::of(&QWebSocket::errorOccurred), this, &PushNotifications::onWebSocketError); connect(_webSocket, &QWebSocket::sslErrors, this, &PushNotifications::onWebSocketSslErrors); connect(_webSocket, &QWebSocket::connected, this, &PushNotifications::onWebSocketConnected); connect(_webSocket, &QWebSocket::disconnected, this, &PushNotifications::onWebSocketDisconnected); @@ -76,7 +76,7 @@ void PushNotifications::closeWebSocket() _reconnectTimer->stop(); } - disconnect(_webSocket, QOverload::of(&QWebSocket::error), this, &PushNotifications::onWebSocketError); + disconnect(_webSocket, QOverload::of(&QWebSocket::errorOccurred), this, &PushNotifications::onWebSocketError); disconnect(_webSocket, &QWebSocket::sslErrors, this, &PushNotifications::onWebSocketSslErrors); _webSocket->close(); @@ -174,7 +174,7 @@ void PushNotifications::openWebSocket() const auto webSocketUrl = capabilities.pushNotificationsWebSocketUrl(); qCInfo(lcPushNotifications) << "Open connection to websocket on" << webSocketUrl << "for account" << _account->url(); - connect(_webSocket, QOverload::of(&QWebSocket::error), this, &PushNotifications::onWebSocketError); + connect(_webSocket, QOverload::of(&QWebSocket::errorOccurred), this, &PushNotifications::onWebSocketError); connect(_webSocket, &QWebSocket::sslErrors, this, &PushNotifications::onWebSocketSslErrors); _webSocket->open(webSocketUrl); } From 04842ba9ea096f77ab1f437ccfc780fcd9126ccf Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Thu, 28 Nov 2024 18:04:28 +0800 Subject: [PATCH 15/22] Use QDomDocument content method returning ParseResult Signed-off-by: Claudio Cambra Use ParseResult returning QDomDocument setContent Signed-off-by: Claudio Cambra f parseresult Signed-off-by: Claudio Cambra --- src/gui/updater/updateinfo.cpp | 10 ++++------ src/libsync/networkjobs.cpp | 7 ++----- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/src/gui/updater/updateinfo.cpp b/src/gui/updater/updateinfo.cpp index 55512374a1f57..2bfb720fb63a5 100644 --- a/src/gui/updater/updateinfo.cpp +++ b/src/gui/updater/updateinfo.cpp @@ -84,13 +84,11 @@ UpdateInfo UpdateInfo::parseElement(const QDomElement &element, bool *ok) UpdateInfo UpdateInfo::parseString(const QString &xml, bool *ok) { - QString errorMsg; - int errorLine = 0, errorCol = 0; QDomDocument doc; - if (!doc.setContent(xml, false, &errorMsg, &errorLine, &errorCol)) { - qCWarning(lcUpdater).noquote().nospace() << errorMsg << " at " << errorLine << "," << errorCol - << "\n" << xml.split("\n").value(errorLine-1) << "\n" - << QString(" ").repeated(errorCol - 1) << "^\n" + if (const auto result = doc.setContent(xml); !result) { + qCWarning(lcUpdater).noquote().nospace() << result.errorMessage << " at " << result.errorLine << "," << result.errorColumn + << "\n" << xml.split("\n").value(result.errorLine - 1) << "\n" + << QString(" ").repeated(result.errorColumn - 1) << "^\n" << "->" << xml << "<-"; if (ok) *ok = false; diff --git a/src/libsync/networkjobs.cpp b/src/libsync/networkjobs.cpp index 78356f8c92f3d..1cde1a2c15a00 100644 --- a/src/libsync/networkjobs.cpp +++ b/src/libsync/networkjobs.cpp @@ -663,12 +663,9 @@ bool PropfindJob::finished() if (http_result_code == 207) { // Parse DAV response auto domDocument = QDomDocument(); - auto errorMsg = QString(); - auto errorLine = -1; - auto errorColumn = -1; - if (!domDocument.setContent(reply(), true, &errorMsg, &errorLine, &errorColumn)) { - qCWarning(lcPropfindJob) << "XML parser error: " << errorMsg << errorLine << errorColumn; + if (const auto res = domDocument.setContent(reply(), QDomDocument::ParseOption::UseNamespaceProcessing); !res) { + qCWarning(lcPropfindJob) << "XML parser error: " << res.errorMessage << res.errorLine << res.errorColumn; emit finishedWithError(reply()); } else { From 445352b1c62663b9ab139dcd8c429d7d002c2414 Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Fri, 29 Nov 2024 00:59:02 +0800 Subject: [PATCH 16/22] Move pinned Qt and Craft cache versions to 6.8.0 and 24.12 respectively Signed-off-by: Claudio Cambra --- craftmaster.ini | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/craftmaster.ini b/craftmaster.ini index 0bf98f95795c2..2fe495b583dfe 100644 --- a/craftmaster.ini +++ b/craftmaster.ini @@ -27,7 +27,7 @@ ShortPath/EnableJunctions = False Packager/RepositoryUrl = https://files.kde.org/craft/Qt6 Packager/PackageType = NullsoftInstallerPackager -Packager/CacheVersion = 24.08 +Packager/CacheVersion = 24.12 ContinuousIntegration/Enabled = True @@ -42,7 +42,7 @@ Packager/CacheDir = ${Variables:Root}\cache [BlueprintSettings] nextcloud-client.buildTests = True binary/mysql.useMariaDB = False -libs/qt6.version = 6.7.2 +libs/qt6.version = 6.8.0 [windows-msvc2022_64-cl] QtSDK/Compiler = msvc2022_64 From 34c12bce816b14c1e4e5cfe4a3c1ca9c9c296d89 Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Fri, 29 Nov 2024 01:24:40 +0800 Subject: [PATCH 17/22] Use default downloaddir for craft Signed-off-by: Claudio Cambra --- craftmaster.ini | 1 - 1 file changed, 1 deletion(-) diff --git a/craftmaster.ini b/craftmaster.ini index 2fe495b583dfe..7361a102f592f 100644 --- a/craftmaster.ini +++ b/craftmaster.ini @@ -21,7 +21,6 @@ Compile/BuildType = RelWithDebInfo Compile/UseNinja = True -Paths/downloaddir = ${Variables:Root}\downloads ShortPath/Enabled = False ShortPath/EnableJunctions = False From f07b12081bf12179ac6a667135116b20900ff9e1 Mon Sep 17 00:00:00 2001 From: Matthieu Gallien Date: Tue, 3 Dec 2024 18:09:12 +0100 Subject: [PATCH 18/22] use CI images with Qt 6.8.0 Signed-off-by: Matthieu Gallien --- .github/workflows/clang-tidy-review.yml | 4 ++-- .github/workflows/linux-appimage.yml | 4 ++-- .github/workflows/linux-clang-compile-tests.yml | 4 ++-- .github/workflows/linux-gcc-compile-tests.yml | 4 ++-- .github/workflows/sonarcloud.yml | 4 ++-- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/.github/workflows/clang-tidy-review.yml b/.github/workflows/clang-tidy-review.yml index e818aed830c15..55481cf8209c9 100644 --- a/.github/workflows/clang-tidy-review.yml +++ b/.github/workflows/clang-tidy-review.yml @@ -7,14 +7,14 @@ on: jobs: clang-tidy: runs-on: ubuntu-latest - container: ghcr.io/nextcloud/continuous-integration-client-qt6:client-6.7.3-1 + container: ghcr.io/nextcloud/continuous-integration-client-qt6:client-6.8.0-1 steps: - uses: actions/checkout@v4 with: fetch-depth: 2 - name: Prepare compile_commands.json run: | - cmake -G Ninja -B build -DCMAKE_PREFIX_PATH=/opt/qt6.7.3 -DQT_MAJOR_VERSION=6 -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DBUILD_UPDATER=ON -DBUILD_TESTING=1 -DOPENSSL_ROOT_DIR=/usr/local/lib64 + cmake -G Ninja -B build -DCMAKE_PREFIX_PATH=/opt/qt6.8.0 -DQT_MAJOR_VERSION=6 -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DBUILD_UPDATER=ON -DBUILD_TESTING=1 -DOPENSSL_ROOT_DIR=/usr/local/lib64 cd build && ninja - name: Create results directory run: | diff --git a/.github/workflows/linux-appimage.yml b/.github/workflows/linux-appimage.yml index 2c4bcd0b8d248..02cc7a4b365b4 100644 --- a/.github/workflows/linux-appimage.yml +++ b/.github/workflows/linux-appimage.yml @@ -6,12 +6,12 @@ jobs: build: name: Linux Appimage Package runs-on: ubuntu-latest - container: ghcr.io/nextcloud/continuous-integration-client-appimage-qt6:client-appimage-6.7.3-1 + container: ghcr.io/nextcloud/continuous-integration-client-appimage-qt6:client-appimage-6.8.0-1 steps: - uses: actions/checkout@v4 with: fetch-depth: 1 - name: Configure, compile and package run: | - BUILDNR=${GITHUB_RUN_ID} VERSION_SUFFIX=${GITHUB_HEAD_REF} BUILD_UPDATER=ON DESKTOP_CLIENT_ROOT=`pwd` EXECUTABLE_NAME=nextcloud QT_BASE_DIR=/opt/qt6.7.3 OPENSSL_ROOT_DIR=/usr/local/lib64 /bin/bash -c "./admin/linux/build-appimage.sh" + BUILDNR=${GITHUB_RUN_ID} VERSION_SUFFIX=${GITHUB_HEAD_REF} BUILD_UPDATER=ON DESKTOP_CLIENT_ROOT=`pwd` EXECUTABLE_NAME=nextcloud QT_BASE_DIR=/opt/qt6.8.0 OPENSSL_ROOT_DIR=/usr/local/lib64 /bin/bash -c "./admin/linux/build-appimage.sh" BUILDNR=${GITHUB_RUN_ID} VERSION_SUFFIX=${GITHUB_HEAD_REF} DESKTOP_CLIENT_ROOT=`pwd` /bin/bash -c "./admin/linux/upload-appimage.sh" || echo "Upload failed, however this is an optional step." diff --git a/.github/workflows/linux-clang-compile-tests.yml b/.github/workflows/linux-clang-compile-tests.yml index ce0a62b76792e..534b8a70e1cc3 100644 --- a/.github/workflows/linux-clang-compile-tests.yml +++ b/.github/workflows/linux-clang-compile-tests.yml @@ -6,7 +6,7 @@ jobs: build: name: Linux Clang compilation and tests runs-on: ubuntu-latest - container: ghcr.io/nextcloud/continuous-integration-client-qt6:client-6.7.3-1 + container: ghcr.io/nextcloud/continuous-integration-client-qt6:client-6.8.0-1 steps: - uses: actions/checkout@v4 with: @@ -15,7 +15,7 @@ jobs: run: | mkdir build cd build - cmake .. -G Ninja -DCMAKE_PREFIX_PATH=/opt/qt6.7.3 -DCMAKE_C_COMPILER=clang-14 -DCMAKE_CXX_COMPILER=clang++-14 -DCMAKE_BUILD_TYPE=Debug -DQT_MAJOR_VERSION=6 -DQUICK_COMPILER=ON -DBUILD_UPDATER=ON -DBUILD_TESTING=1 -DCMAKE_CXX_FLAGS=-Werror -DOPENSSL_ROOT_DIR=/usr/local/lib64 + cmake .. -G Ninja -DCMAKE_PREFIX_PATH=/opt/qt6.8.0 -DCMAKE_C_COMPILER=clang-14 -DCMAKE_CXX_COMPILER=clang++-14 -DCMAKE_BUILD_TYPE=Debug -DQT_MAJOR_VERSION=6 -DQUICK_COMPILER=ON -DBUILD_UPDATER=ON -DBUILD_TESTING=1 -DCMAKE_CXX_FLAGS=-Werror -DOPENSSL_ROOT_DIR=/usr/local/lib64 ninja - name: Run tests run: | diff --git a/.github/workflows/linux-gcc-compile-tests.yml b/.github/workflows/linux-gcc-compile-tests.yml index 8a4a0b6178924..e904c10372c88 100644 --- a/.github/workflows/linux-gcc-compile-tests.yml +++ b/.github/workflows/linux-gcc-compile-tests.yml @@ -6,7 +6,7 @@ jobs: build: name: Linux GCC compilation and tests runs-on: ubuntu-latest - container: ghcr.io/nextcloud/continuous-integration-client-qt6:client-6.7.3-1 + container: ghcr.io/nextcloud/continuous-integration-client-qt6:client-6.8.0-1 steps: - uses: actions/checkout@v4 with: @@ -15,7 +15,7 @@ jobs: run: | mkdir build cd build - cmake .. -G Ninja -DCMAKE_PREFIX_PATH=/opt/qt6.7.3 -DCMAKE_C_COMPILER=gcc-11 -DCMAKE_CXX_COMPILER=g++-11 -DCMAKE_BUILD_TYPE=Debug -DQT_MAJOR_VERSION=6 -DQUICK_COMPILER=ON -DBUILD_UPDATER=ON -DBUILD_TESTING=1 -DCMAKE_CXX_FLAGS=-Werror -DOPENSSL_ROOT_DIR=/usr/local/lib64 + cmake .. -G Ninja -DCMAKE_PREFIX_PATH=/opt/qt6.8.0 -DCMAKE_C_COMPILER=gcc-11 -DCMAKE_CXX_COMPILER=g++-11 -DCMAKE_BUILD_TYPE=Debug -DQT_MAJOR_VERSION=6 -DQUICK_COMPILER=ON -DBUILD_UPDATER=ON -DBUILD_TESTING=1 -DCMAKE_CXX_FLAGS=-Werror -DOPENSSL_ROOT_DIR=/usr/local/lib64 ninja - name: Run tests run: | diff --git a/.github/workflows/sonarcloud.yml b/.github/workflows/sonarcloud.yml index 814dd4aefa3fa..74cc93fe40e2b 100644 --- a/.github/workflows/sonarcloud.yml +++ b/.github/workflows/sonarcloud.yml @@ -6,7 +6,7 @@ jobs: build: name: SonarCloud analysis runs-on: ubuntu-latest - container: ghcr.io/nextcloud/continuous-integration-client-qt6:client-6.7.3-1 + container: ghcr.io/nextcloud/continuous-integration-client-qt6:client-6.8.0-1 env: SONAR_SERVER_URL: "https://sonarcloud.io" BUILD_WRAPPER_OUT_DIR: build_wrapper_output_directory # Directory where build-wrapper output will be placed @@ -25,7 +25,7 @@ jobs: run: | mkdir build cd build - cmake .. -G Ninja -DCMAKE_PREFIX_PATH=/opt/qt6.7.3 -DCMAKE_C_COMPILER=gcc-11 -DCMAKE_CXX_COMPILER=g++-11 -DCMAKE_BUILD_TYPE=Debug -DQUICK_COMPILER=ON -DBUILD_UPDATER=ON -DBUILD_TESTING=1 -DQT_MAJOR_VERSION=6 -DCMAKE_CXX_FLAGS=-Werror -DOPENSSL_ROOT_DIR=/usr/local/lib64 -DBUILD_COVERAGE=ON -DCMAKE_EXPORT_COMPILE_COMMANDS=ON + cmake .. -G Ninja -DCMAKE_PREFIX_PATH=/opt/qt6.8.0 -DCMAKE_C_COMPILER=gcc-11 -DCMAKE_CXX_COMPILER=g++-11 -DCMAKE_BUILD_TYPE=Debug -DQUICK_COMPILER=ON -DBUILD_UPDATER=ON -DBUILD_TESTING=1 -DQT_MAJOR_VERSION=6 -DCMAKE_CXX_FLAGS=-Werror -DOPENSSL_ROOT_DIR=/usr/local/lib64 -DBUILD_COVERAGE=ON -DCMAKE_EXPORT_COMPILE_COMMANDS=ON build-wrapper-linux-x86-64 --out-dir ${{ env.BUILD_WRAPPER_OUT_DIR }} ninja - name: Run tests run: | From b118b806ed3b8a0edf08d17279dfe82faf77f662 Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Thu, 5 Dec 2024 11:38:12 +0800 Subject: [PATCH 19/22] Replace aAsConst with std::as_const in tests Signed-off-by: Claudio Cambra --- test/syncenginetestutils.cpp | 6 +++--- test/testsyncconflict.cpp | 2 +- test/testsyncengine.cpp | 2 +- test/testsyncjournaldb.cpp | 4 ++-- test/testsyncmove.cpp | 4 ++-- test/testsyncvirtualfiles.cpp | 2 +- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/test/syncenginetestutils.cpp b/test/syncenginetestutils.cpp index d3f351f1c725d..30c6254e5bfb6 100644 --- a/test/syncenginetestutils.cpp +++ b/test/syncenginetestutils.cpp @@ -585,7 +585,7 @@ void FakePutMultiFileReply::respond() totalSize += fileInfo->size; }); - for(auto fileInfo : qAsConst(_allFileInfo)) { + for(auto fileInfo : std::as_const(_allFileInfo)) { QJsonObject fileInfoReply; fileInfoReply.insert("error", QStringLiteral("false")); fileInfoReply.insert("etag", QLatin1String{fileInfo->etag}); @@ -1045,12 +1045,12 @@ QJsonObject FakeQNAM::forEachReplyPart(QIODevice *outgoingData, const QString boundaryValue = QStringLiteral("--") + contentType.mid(boundaryPosition, contentType.length() - boundaryPosition - 1) + QStringLiteral("\r\n"); auto stringPutPayloadRef = QString{stringPutPayload}.left(stringPutPayload.size() - 2 - boundaryValue.size()); auto allParts = stringPutPayloadRef.split(boundaryValue, Qt::SkipEmptyParts); - for (const auto &onePart : qAsConst(allParts)) { + for (const auto &onePart : std::as_const(allParts)) { auto headerEndPosition = onePart.indexOf(QStringLiteral("\r\n\r\n")); auto onePartHeaderPart = onePart.left(headerEndPosition); auto onePartHeaders = onePartHeaderPart.split(QStringLiteral("\r\n")); QMap allHeaders; - for(const auto &oneHeader : qAsConst(onePartHeaders)) { + for(const auto &oneHeader : std::as_const(onePartHeaders)) { auto headerParts = oneHeader.split(QStringLiteral(": ")); allHeaders[headerParts.at(0).toLower()] = headerParts.at(1).toLatin1(); } diff --git a/test/testsyncconflict.cpp b/test/testsyncconflict.cpp index ce358feeddb66..1db24cf24e7cc 100644 --- a/test/testsyncconflict.cpp +++ b/test/testsyncconflict.cpp @@ -45,7 +45,7 @@ bool expectAndWipeConflict(FileModifier &local, FileInfo state, const QString pa auto base = state.find(pathComponents.parentDirComponents()); if (!base) return false; - for (const auto &item : qAsConst(base->children)) { + for (const auto &item : std::as_const(base->children)) { if (item.name.startsWith(pathComponents.fileName()) && item.name.contains("(conflicted copy")) { local.remove(item.path()); return true; diff --git a/test/testsyncengine.cpp b/test/testsyncengine.cpp index c745ddcad4ffe..079dd18c1f943 100644 --- a/test/testsyncengine.cpp +++ b/test/testsyncengine.cpp @@ -41,7 +41,7 @@ bool expectConflict(FileInfo state, const QString path) auto base = state.find(pathComponents.parentDirComponents()); if (!base) return false; - for (const auto &item : qAsConst(base->children)) { + for (const auto &item : std::as_const(base->children)) { if (item.name.startsWith(pathComponents.fileName()) && item.name.contains("(case clash from")) { return true; } diff --git a/test/testsyncjournaldb.cpp b/test/testsyncjournaldb.cpp index 426b5bfd836d6..d5897bdf75627 100644 --- a/test/testsyncjournaldb.cpp +++ b/test/testsyncjournaldb.cpp @@ -293,13 +293,13 @@ private slots: << "foo bla bar/file" << "fo_" << "fo_/file"; - for (const auto& elem : qAsConst(elements)) { + for (const auto& elem : std::as_const(elements)) { makeEntry(elem); } auto checkElements = [&]() { bool ok = true; - for (const auto& elem : qAsConst(elements)) { + for (const auto& elem : std::as_const(elements)) { SyncJournalFileRecord record; if (!_db.getFileRecord(elem, &record) || !record.isValid()) { qWarning() << "Missing record: " << elem; diff --git a/test/testsyncmove.cpp b/test/testsyncmove.cpp index 1475013cf3226..8b5ef5806aae3 100644 --- a/test/testsyncmove.cpp +++ b/test/testsyncmove.cpp @@ -77,7 +77,7 @@ bool expectAndWipeConflict(FileModifier &local, FileInfo state, const QString pa auto base = state.find(pathComponents.parentDirComponents()); if (!base) return false; - for (const auto &item : qAsConst(base->children)) { + for (const auto &item : std::as_const(base->children)) { if (item.name.startsWith(pathComponents.fileName()) && item.name.contains("(conflicted copy")) { local.remove(item.path()); return true; @@ -669,7 +669,7 @@ private slots: } conflicts = findConflicts(currentLocal.children["B4"]); QCOMPARE(conflicts.size(), 1); - for (const auto& c : qAsConst(conflicts)) { + for (const auto& c : std::as_const(conflicts)) { QCOMPARE(currentLocal.find(c)->contentChar, 'L'); local.remove(c); } diff --git a/test/testsyncvirtualfiles.cpp b/test/testsyncvirtualfiles.cpp index c50d471ce44cc..47dabce84f2a2 100644 --- a/test/testsyncvirtualfiles.cpp +++ b/test/testsyncvirtualfiles.cpp @@ -32,7 +32,7 @@ bool expectConflict(FileInfo state, const QString path) auto base = state.find(pathComponents.parentDirComponents()); if (!base) return false; - for (const auto &item : qAsConst(base->children)) { + for (const auto &item : std::as_const(base->children)) { if (item.name.startsWith(pathComponents.fileName()) && item.name.contains("(case clash from")) { return true; } From 3356d77708d73d9da033ced86fea7840b85b77ef Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Thu, 5 Dec 2024 12:15:44 +0800 Subject: [PATCH 20/22] Use non-deprecated qChecksum in qtlocalpeer of qtsingleapplication Signed-off-by: Claudio Cambra --- src/3rdparty/qtsingleapplication/qtlocalpeer.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/3rdparty/qtsingleapplication/qtlocalpeer.cpp b/src/3rdparty/qtsingleapplication/qtlocalpeer.cpp index 4be57a0286cdb..8afab3e079e75 100644 --- a/src/3rdparty/qtsingleapplication/qtlocalpeer.cpp +++ b/src/3rdparty/qtsingleapplication/qtlocalpeer.cpp @@ -51,8 +51,8 @@ static const char ack[] = "ack"; QString QtLocalPeer::appSessionId(const QString &appId) { - QByteArray idc = appId.toUtf8(); - quint16 idNum = qChecksum(idc.constData(), idc.size()); + const auto idc = appId.toUtf8(); + const auto idNum = qChecksum(idc); //### could do: two 16bit checksums over separate halves of id, for a 32bit result - improved uniqeness probability. Every-other-char split would be best. QString res = QLatin1String("qtsingleapplication-") From beeca9abaa9095efd65949e5c39ae19ee6cf8c60 Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Thu, 5 Dec 2024 15:28:07 +0800 Subject: [PATCH 21/22] Use QTimeZone in startOfDay for QDate in tests Signed-off-by: Claudio Cambra --- test/testdatefieldbackend.cpp | 8 ++++---- test/testsharemodel.cpp | 10 +++++----- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/test/testdatefieldbackend.cpp b/test/testdatefieldbackend.cpp index 2ce760813b743..96f2ba1dafa64 100644 --- a/test/testdatefieldbackend.cpp +++ b/test/testdatefieldbackend.cpp @@ -44,7 +44,7 @@ private slots: backend._dateFormat = dateStringFormat; const auto currentDate = QDate::currentDate(); - const auto currentDateMSecs = currentDate.startOfDay(Qt::UTC).toMSecsSinceEpoch(); + const auto currentDateMSecs = currentDate.startOfDay(QTimeZone::utc()).toMSecsSinceEpoch(); const auto currentDateString = currentDate.toString(dateStringFormat); QCOMPARE(backend.date(), currentDate); @@ -64,8 +64,8 @@ private slots: const auto minDate = QDate::currentDate().addDays(-5); const auto maxDate = QDate::currentDate().addDays(5); - const auto minDateMs = minDate.startOfDay(Qt::UTC).toMSecsSinceEpoch(); - const auto maxDateMs = maxDate.startOfDay(Qt::UTC).toMSecsSinceEpoch(); + const auto minDateMs = minDate.startOfDay(QTimeZone::utc()).toMSecsSinceEpoch(); + const auto maxDateMs = maxDate.startOfDay(QTimeZone::utc()).toMSecsSinceEpoch(); const auto invalidMinDate = minDate.addDays(-1); const auto invalidMaxDate = maxDate.addDays(1); @@ -124,7 +124,7 @@ private slots: QSignalSpy dateStringChangedSpy(&backend, &Quick::DateFieldBackend::dateStringChanged); const auto testDate = QDate::currentDate().addDays(800); - const auto testDateMsecs = testDate.startOfDay(Qt::UTC).toMSecsSinceEpoch(); + const auto testDateMsecs = testDate.startOfDay(QTimeZone::utc()).toMSecsSinceEpoch(); const auto testDateString = testDate.toString(dateStringFormat); backend.setDate(testDate); diff --git a/test/testsharemodel.cpp b/test/testsharemodel.cpp index 5d8800985b905..6abfe79ce731a 100644 --- a/test/testsharemodel.cpp +++ b/test/testsharemodel.cpp @@ -278,7 +278,7 @@ private slots: const auto expectedLinkShareExpireDate = QDate::fromString(_testLinkShareDefinition.shareExpiration, helper.expectedDtFormat); QCOMPARE(shareIndex.data(ShareModel::ExpireDateEnabledRole).toBool(), expectedLinkShareExpireDate.isValid()); - QCOMPARE(shareIndex.data(ShareModel::ExpireDateRole).toLongLong(), expectedLinkShareExpireDate.startOfDay(Qt::UTC).toMSecsSinceEpoch()); + QCOMPARE(shareIndex.data(ShareModel::ExpireDateRole).toLongLong(), expectedLinkShareExpireDate.startOfDay(QTimeZone::utc()).toMSecsSinceEpoch()); const auto iconUrl = shareIndex.data(ShareModel::IconUrlRole).toString(); QVERIFY(iconUrl.contains("public.svg")); @@ -321,7 +321,7 @@ private slots: const auto expectedShareExpireDate = QDate::fromString(_testEmailShareDefinition.shareExpiration, helper.expectedDtFormat); QCOMPARE(shareIndex.data(ShareModel::ExpireDateEnabledRole).toBool(), expectedShareExpireDate.isValid()); - QCOMPARE(shareIndex.data(ShareModel::ExpireDateRole).toLongLong(), expectedShareExpireDate.startOfDay(Qt::UTC).toMSecsSinceEpoch()); + QCOMPARE(shareIndex.data(ShareModel::ExpireDateRole).toLongLong(), expectedShareExpireDate.startOfDay(QTimeZone::utc()).toMSecsSinceEpoch()); const auto iconUrl = shareIndex.data(ShareModel::IconUrlRole).toString(); QVERIFY(iconUrl.contains("email.svg")); @@ -364,7 +364,7 @@ private slots: const auto expectedShareExpireDate = QDate::fromString(_testUserShareDefinition.shareExpiration, helper.expectedDtFormat); QCOMPARE(shareIndex.data(ShareModel::ExpireDateEnabledRole).toBool(), expectedShareExpireDate.isValid()); - QCOMPARE(shareIndex.data(ShareModel::ExpireDateRole).toLongLong(), expectedShareExpireDate.startOfDay(Qt::UTC).toMSecsSinceEpoch()); + QCOMPARE(shareIndex.data(ShareModel::ExpireDateRole).toLongLong(), expectedShareExpireDate.startOfDay(QTimeZone::utc()).toMSecsSinceEpoch()); const auto iconUrl = shareIndex.data(ShareModel::IconUrlRole).toString(); QVERIFY(iconUrl.contains("user.svg")); @@ -801,14 +801,14 @@ private slots: QCOMPARE(shareIndex.data(ShareModel::ExpireDateEnabledRole).toBool(), false); // Set a new expire date - const auto expireDateMsecs = QDate::currentDate().addDays(10).startOfDay(Qt::UTC).toMSecsSinceEpoch(); + const auto expireDateMsecs = QDate::currentDate().addDays(10).startOfDay(QTimeZone::utc()).toMSecsSinceEpoch(); model.setShareExpireDate(linkSharePtr, expireDateMsecs); QVERIFY(expireDateSet.wait(3000)); QCOMPARE(shareIndex.data(ShareModel::ExpireDateRole).toLongLong(), expireDateMsecs); QCOMPARE(shareIndex.data(ShareModel::ExpireDateEnabledRole).toBool(), true); // Test the QML-specific slot - const QVariant newExpireDateMsecs = QDate::currentDate().addDays(20).startOfDay(Qt::UTC).toMSecsSinceEpoch(); + const QVariant newExpireDateMsecs = QDate::currentDate().addDays(20).startOfDay(QTimeZone::utc()).toMSecsSinceEpoch(); model.setShareExpireDateFromQml(QVariant::fromValue(sharePtr), newExpireDateMsecs); QVERIFY(expireDateSet.wait(3000)); QCOMPARE(shareIndex.data(ShareModel::ExpireDateRole).toLongLong(), newExpireDateMsecs); From 92eb18a9406106c369b4d92807289d1e7d4e6391 Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Thu, 5 Dec 2024 15:40:00 +0800 Subject: [PATCH 22/22] Use std::next rather than adding to iterator in tests Signed-off-by: Claudio Cambra --- test/testchunkingng.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/testchunkingng.cpp b/test/testchunkingng.cpp index 87612fab538a1..35d08f02e0b06 100644 --- a/test/testchunkingng.cpp +++ b/test/testchunkingng.cpp @@ -178,7 +178,7 @@ private slots: // Remove the second chunk, so all further chunks will be deleted and resent auto firstChunk = chunkMap.first(); - auto secondChunk = *(chunkMap.begin() + 1); + auto secondChunk = *(std::next(chunkMap.begin())); const auto chunksList = chunkMap.keys().mid(2); for (const auto& name : chunksList) { chunksToDelete.append(name);