Fix a possible crash with the remove all files dialog
authorHannah von Reth <hannah.vonreth@owncloud.com>
Fri, 18 Dec 2020 11:48:08 +0000 (12:48 +0100)
committerKevin Ottens <kevin.ottens@nextcloud.com>
Wed, 30 Dec 2020 15:20:43 +0000 (16:20 +0100)
src/gui/folder.cpp
src/libsync/syncengine.cpp

index 7429811952c6c4205c1fd96309a17b33754da032..4f8c1e1522e4efaaf6a8fae12757d852d8492855 100644 (file)
@@ -1260,6 +1260,7 @@ void Folder::slotAboutToRemoveAllFiles(SyncFileItem::Direction dir, std::functio
         }
         setSyncPaused(oldPaused);
     });
+    connect(this, &Folder::destroyed, msgBox, &QMessageBox::deleteLater);
     msgBox->open();
 }
 
index 7d6ae74d3cfc30d3dba87bf36ee2be832e3c6e08..89d4057fcf22fecdf55402ef80e2925c1acfe55e 100644 (file)
@@ -737,10 +737,11 @@ void SyncEngine::slotDiscoveryFinished()
         }
 
         QPointer<QObject> guard = new QObject();
-        auto callback = [this, finish, guard](bool cancel) -> void {
+        QPointer<QObject> self = this;
+        auto callback = [this, self, finish, guard](bool cancel) -> void {
             // use a guard to ensure its only called once...
-            if (!guard)
-            {
+            // qpointer to self to ensure we still exist
+            if (!guard || !self) {
                 return;
             }
             guard->deleteLater();