Stop leaking PropagateDownloadEncrypted objects
authorKevin Ottens <kevin.ottens@nextcloud.com>
Wed, 24 Jun 2020 15:58:52 +0000 (17:58 +0200)
committerKevin Ottens <kevin.ottens@nextcloud.com>
Tue, 30 Jun 2020 09:29:08 +0000 (11:29 +0200)
We give them a parent to make sure they will be destroyed when the jobs
which created them are destroyed themselves.

Signed-off-by: Kevin Ottens <kevin.ottens@nextcloud.com>
src/libsync/propagatedownload.cpp
src/libsync/propagatedownloadencrypted.cpp
src/libsync/propagatedownloadencrypted.h

index 6b85e2f70c472af345aa27e127a572239526caf8..67a7a4264dab028d88eaff0e7d1b6bf50e880210 100644 (file)
@@ -344,7 +344,7 @@ void PropagateDownloadFile::start()
     qCDebug(lcPropagateDownload) << _item->_file << propagator()->_activeJobList.count();
 
     if (propagator()->account()->capabilities().clientSideEncryptionAvailable()) {
-        _downloadEncryptedHelper = new PropagateDownloadEncrypted(propagator(), _item);
+        _downloadEncryptedHelper = new PropagateDownloadEncrypted(propagator(), _item, this);
         connect(_downloadEncryptedHelper, &PropagateDownloadEncrypted::folderStatusNotEncrypted, [this] {
           startAfterIsEncryptedIsChecked();
         });
index f807cadcec000f2caa42806c204a1d96a55eccb8..ace382d84b452d0ad0e82f9660d08d479c339828 100644 (file)
@@ -6,9 +6,11 @@ Q_LOGGING_CATEGORY(lcPropagateDownloadEncrypted, "nextcloud.sync.propagator.down
 
 namespace OCC {
 
-PropagateDownloadEncrypted::PropagateDownloadEncrypted(OwncloudPropagator *propagator, SyncFileItemPtr item) :
- _propagator(propagator), _item(item), _info(_item->_file)
-
+PropagateDownloadEncrypted::PropagateDownloadEncrypted(OwncloudPropagator *propagator, SyncFileItemPtr item, QObject *parent)
+    : QObject(parent)
+    , _propagator(propagator)
+    , _item(item)
+    , _info(_item->_file)
 {
 }
 
index 98dc788af7fcec4711565dca64bf70ced0a8e2eb..b2a6b9475472d92e8db22fb01cbc80e9af4d608e 100644 (file)
@@ -15,7 +15,7 @@ namespace OCC {
 class PropagateDownloadEncrypted : public QObject {
   Q_OBJECT
 public:
-  PropagateDownloadEncrypted(OwncloudPropagator *propagator, SyncFileItemPtr item);
+  PropagateDownloadEncrypted(OwncloudPropagator *propagator, SyncFileItemPtr item, QObject *parent = nullptr);
   void start();
   void checkFolderId(const QStringList &list);
   bool decryptFile(QFile& tmpFile);