From: Claudio Cambra Date: Fri, 28 Oct 2022 22:19:04 +0000 (+0200) Subject: Ensure the checkTokenJob object gets deallocated X-Git-Tag: archive/raspbian/3.16.7-1_deb13u1+rpi1~1^2~12^2~11^2~177^2~1 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=ee8b12009ae096637f2773f254e7133f3a5e29e5;p=nextcloud-desktop.git Ensure the checkTokenJob object gets deallocated Signed-off-by: Claudio Cambra --- diff --git a/src/gui/editlocallyhandler.cpp b/src/gui/editlocallyhandler.cpp index 74396b20c..50e22698a 100644 --- a/src/gui/editlocallyhandler.cpp +++ b/src/gui/editlocallyhandler.cpp @@ -93,15 +93,17 @@ void EditLocallyHandler::startTokenRemoteCheck() const auto encodedToken = QString::fromUtf8(QUrl::toPercentEncoding(_token)); // Sanitise the token const auto encodedRelPath = QUrl::toPercentEncoding(_relPath); // Sanitise the relPath - const auto checkEditLocallyToken = new SimpleApiJob(_accountState->account(), QStringLiteral("/ocs/v2.php/apps/files/api/v1/openlocaleditor/%1").arg(encodedToken)); + + _checkTokenJob.reset(new SimpleApiJob(_accountState->account(), + QStringLiteral("/ocs/v2.php/apps/files/api/v1/openlocaleditor/%1").arg(encodedToken))); QUrlQuery params; params.addQueryItem(QStringLiteral("path"), prefixSlashToPath(encodedRelPath)); - checkEditLocallyToken->addQueryParams(params); - checkEditLocallyToken->setVerb(SimpleApiJob::Verb::Post); - connect(checkEditLocallyToken, &SimpleApiJob::resultReceived, this, &EditLocallyHandler::remoteTokenCheckResultReceived); + _checkTokenJob->addQueryParams(params); + _checkTokenJob->setVerb(SimpleApiJob::Verb::Post); + connect(_checkTokenJob.get(), &SimpleApiJob::resultReceived, this, &EditLocallyHandler::remoteTokenCheckResultReceived); - checkEditLocallyToken->start(); + _checkTokenJob->start(); } void EditLocallyHandler::remoteTokenCheckResultReceived(const int statusCode) diff --git a/src/gui/editlocallyhandler.h b/src/gui/editlocallyhandler.h index 05b3076e7..0093191b8 100644 --- a/src/gui/editlocallyhandler.h +++ b/src/gui/editlocallyhandler.h @@ -75,6 +75,7 @@ private: QString _fileName; QString _localFilePath; Folder *_folderForFile = nullptr; + std::unique_ptr _checkTokenJob; }; }