From e9a0dbd16cce84c54adb2def4bb38f570083db33 Mon Sep 17 00:00:00 2001 From: alex-z Date: Fri, 5 Jan 2024 17:57:38 +0100 Subject: [PATCH] Allow event processing between each XML parser run, to improve GUI performance. Signed-off-by: alex-z --- src/gui/editlocallyjob.cpp | 2 +- src/gui/folderstatusmodel.cpp | 2 +- src/gui/folderwizard.cpp | 2 +- src/gui/selectivesyncdialog.cpp | 4 ++-- src/gui/shellextensionsserver.cpp | 2 +- src/libsync/discoveryphase.cpp | 2 +- src/libsync/encryptedfoldermetadatahandler.cpp | 2 +- src/libsync/networkjobs.cpp | 17 +++++++++++++---- src/libsync/networkjobs.h | 4 ++-- src/libsync/propagateuploadng.cpp | 2 +- 10 files changed, 24 insertions(+), 15 deletions(-) diff --git a/src/gui/editlocallyjob.cpp b/src/gui/editlocallyjob.cpp index d20a9bb699c57..167cf99c33cb9 100644 --- a/src/gui/editlocallyjob.cpp +++ b/src/gui/editlocallyjob.cpp @@ -206,7 +206,7 @@ void EditLocallyJob::fetchRemoteFileParentInfo() return; } - const auto job = new LsColJob(_accountState->account(), QDir::cleanPath(_folderForFile->remotePathTrailingSlash() + _relPathParent), this); + const auto job = new LsColJob(_accountState->account(), QDir::cleanPath(_folderForFile->remotePathTrailingSlash() + _relPathParent)); const QList props{QByteArrayLiteral("resourcetype"), QByteArrayLiteral("getlastmodified"), QByteArrayLiteral("getetag"), diff --git a/src/gui/folderstatusmodel.cpp b/src/gui/folderstatusmodel.cpp index 5bc886809e8e9..9eb505be36eea 100644 --- a/src/gui/folderstatusmodel.cpp +++ b/src/gui/folderstatusmodel.cpp @@ -614,7 +614,7 @@ void FolderStatusModel::fetchMore(const QModelIndex &parent) path += infoPath; } - auto *job = new LsColJob(_accountState->account(), path, this); + auto *job = new LsColJob(_accountState->account(), path); info->_fetchingJob = job; auto props = QList() << "resourcetype" << "http://owncloud.org/ns:size" diff --git a/src/gui/folderwizard.cpp b/src/gui/folderwizard.cpp index 84fa76d0489e5..87bf4e5e48516 100644 --- a/src/gui/folderwizard.cpp +++ b/src/gui/folderwizard.cpp @@ -464,7 +464,7 @@ void FolderWizardRemotePath::slotTypedPathFound(const QStringList &subpaths) LsColJob *FolderWizardRemotePath::runLsColJob(const QString &path) { - auto *job = new LsColJob(_account, path, this); + auto *job = new LsColJob(_account, path); auto props = QList() << "resourcetype"; if (_account->capabilities().clientSideEncryptionAvailable()) { props << "http://nextcloud.org/ns:is-encrypted"; diff --git a/src/gui/selectivesyncdialog.cpp b/src/gui/selectivesyncdialog.cpp index 1250a595e48b1..595fde87c2c7a 100644 --- a/src/gui/selectivesyncdialog.cpp +++ b/src/gui/selectivesyncdialog.cpp @@ -107,7 +107,7 @@ void SelectiveSyncWidget::refreshFolders() { _encryptedPaths.clear(); - auto *job = new LsColJob(_account, _folderPath, this); + auto *job = new LsColJob(_account, _folderPath); auto props = QList() << "resourcetype" << "http://owncloud.org/ns:size"; if (_account->capabilities().clientSideEncryptionAvailable()) { @@ -336,7 +336,7 @@ void SelectiveSyncWidget::slotItemExpanded(QTreeWidgetItem *item) if (!_folderPath.isEmpty()) { prefix = _folderPath + QLatin1Char('/'); } - auto *job = new LsColJob(_account, prefix + dir, this); + auto *job = new LsColJob(_account, prefix + dir); job->setProperties(QList() << "resourcetype" << "http://owncloud.org/ns:size"); connect(job, &LsColJob::directoryListingSubfolders, diff --git a/src/gui/shellextensionsserver.cpp b/src/gui/shellextensionsserver.cpp index b015831166a8f..88c5571b8b128 100644 --- a/src/gui/shellextensionsserver.cpp +++ b/src/gui/shellextensionsserver.cpp @@ -168,7 +168,7 @@ void ShellExtensionsServer::processCustomStateRequest(QLocalSocket *socket, cons closeSession(socket); })); - auto *const lsColJob = new LsColJob(folder->accountState()->account(), QDir::cleanPath(folder->remotePath() + lsColJobPath), this); + auto *const lsColJob = new LsColJob(folder->accountState()->account(), QDir::cleanPath(folder->remotePath() + lsColJobPath)); lsColJob->setProperties({QByteArrayLiteral("http://owncloud.org/ns:share-types"), QByteArrayLiteral("http://owncloud.org/ns:permissions")}); const auto folderAlias = customStateRequestInfo.folderAlias; diff --git a/src/libsync/discoveryphase.cpp b/src/libsync/discoveryphase.cpp index 68e91bdd26f74..7ae2022841803 100644 --- a/src/libsync/discoveryphase.cpp +++ b/src/libsync/discoveryphase.cpp @@ -378,7 +378,7 @@ DiscoverySingleDirectoryJob::DiscoverySingleDirectoryJob(const AccountPtr &accou void DiscoverySingleDirectoryJob::start() { // Start the actual HTTP job - auto *lsColJob = new LsColJob(_account, _subPath, this); + auto *lsColJob = new LsColJob(_account, _subPath); QList props; props << "resourcetype" diff --git a/src/libsync/encryptedfoldermetadatahandler.cpp b/src/libsync/encryptedfoldermetadatahandler.cpp index 63de59f900eab..6771b6170eb50 100644 --- a/src/libsync/encryptedfoldermetadatahandler.cpp +++ b/src/libsync/encryptedfoldermetadatahandler.cpp @@ -99,7 +99,7 @@ void EncryptedFolderMetadataHandler::startFetchMetadata() void EncryptedFolderMetadataHandler::fetchFolderEncryptedId() { qCDebug(lcFetchAndUploadE2eeFolderMetadataJob) << "Folder is encrypted, let's get the Id from it."; - const auto job = new LsColJob(_account, _folderPath, this); + const auto job = new LsColJob(_account, _folderPath); job->setProperties({"resourcetype", "http://owncloud.org/ns:fileid"}); connect(job, &LsColJob::directoryListingSubfolders, this, &EncryptedFolderMetadataHandler::slotFolderEncryptedIdReceived); connect(job, &LsColJob::finishedWithError, this, &EncryptedFolderMetadataHandler::slotFolderEncryptedIdError); diff --git a/src/libsync/networkjobs.cpp b/src/libsync/networkjobs.cpp index 93e220c478b5a..bfef32160b16e 100644 --- a/src/libsync/networkjobs.cpp +++ b/src/libsync/networkjobs.cpp @@ -317,13 +317,13 @@ bool LsColXMLParser::parse(const QByteArray &xml, QHashrequest().url().path(); // something like "/owncloud/remote.php/dav/folder" if (!parser.parse(reply()->readAll(), &_folderInfos, expectedPath)) { // XML parse error @@ -414,6 +421,8 @@ bool LsColJob::finished() emit finishedWithError(reply()); } + this->deleteLater(); + return true; } diff --git a/src/libsync/networkjobs.h b/src/libsync/networkjobs.h index c1337f1cc4002..f623345021238 100644 --- a/src/libsync/networkjobs.h +++ b/src/libsync/networkjobs.h @@ -140,8 +140,8 @@ class OWNCLOUDSYNC_EXPORT LsColJob : public AbstractNetworkJob { Q_OBJECT public: - explicit LsColJob(AccountPtr account, const QString &path, QObject *parent = nullptr); - explicit LsColJob(AccountPtr account, const QUrl &url, QObject *parent = nullptr); + explicit LsColJob(AccountPtr account, const QString &path); + explicit LsColJob(AccountPtr account, const QUrl &url); void start() override; QHash _folderInfos; diff --git a/src/libsync/propagateuploadng.cpp b/src/libsync/propagateuploadng.cpp index f751c58253fbe..f778f79ef6c9a 100644 --- a/src/libsync/propagateuploadng.cpp +++ b/src/libsync/propagateuploadng.cpp @@ -105,7 +105,7 @@ void PropagateUploadFileNG::doStartUpload() if (progressInfo._valid && progressInfo.isChunked() && progressInfo._modtime == _item->_modtime && progressInfo._size == _item->_size) { _transferId = progressInfo._transferid; - const auto job = new LsColJob(propagator()->account(), chunkUploadFolderUrl(), this); + const auto job = new LsColJob(propagator()->account(), chunkUploadFolderUrl()); _jobs.append(job); job->setProperties(QList() << "resourcetype" << "getcontentlength");