Ensure the checkTokenJob object gets deallocated
authorClaudio Cambra <claudio.cambra@nextcloud.com>
Fri, 28 Oct 2022 22:19:04 +0000 (00:19 +0200)
committerClaudio Cambra <claudio.cambra@gmail.com>
Sat, 29 Oct 2022 11:32:48 +0000 (13:32 +0200)
Signed-off-by: Claudio Cambra <claudio.cambra@nextcloud.com>
src/gui/editlocallyhandler.cpp
src/gui/editlocallyhandler.h

index 74396b20ceab5764a3dd275ea37630e0743d3dc4..50e22698a823d43595a180794e6931551e122062 100644 (file)
@@ -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)
index 05b3076e7b9c18c6f0173a102975e9820202233d..0093191b8084902375c0844a4ee66cc7ba3cddc9 100644 (file)
@@ -75,6 +75,7 @@ private:
     QString _fileName;
     QString _localFilePath;
     Folder *_folderForFile = nullptr;
+    std::unique_ptr<SimpleApiJob> _checkTokenJob;
 };
 
 }