]> cloud.milkyroute.net Git - dolphin.git/commitdiff
KFileItemModel: Delay emitting currentDirectoryRemoved() signal
authorAmol Godbole <amolagodbole@gmail.com>
Mon, 4 Sep 2023 05:24:38 +0000 (00:24 -0500)
committerAmol Godbole <amolagodbole@gmail.com>
Mon, 4 Sep 2023 05:53:38 +0000 (00:53 -0500)
The KCoreDirLister object is modified before KCoreDirListerCache::deleteDir()
returns because the signal currentDirectoryRemoved() is emitted.
This prevents removal of the deleted lister from dirData.listersCurrentlyHolding
in KCoreDirListerCache::forgetDirs() when the tab is closed, which causes the
crash described in the bug. Hence, the signal currentDirectoryRemoved()
is delayed to ensure this does not occur.

BUG: 473377

src/kitemviews/kfileitemmodel.cpp

index 40c76c7ef294e7c2503848c94b8ff3a21649599b..f42f2c193877d34183fff9cc82e74f766c39425f 100644 (file)
@@ -1197,7 +1197,12 @@ void KFileItemModel::slotItemsDeleted(const KFileItemList &items)
 
     for (const KFileItem &item : items) {
         if (item.url() == currentDir) {
-            Q_EMIT currentDirectoryRemoved();
+            // #473377: Delay emitting currentDirectoryRemoved() to avoid modifying KCoreDirLister
+            // before KCoreDirListerCache::deleteDir() returns.
+            QTimer::singleShot(0, this, [this] {
+                Q_EMIT currentDirectoryRemoved();
+            });
+
             return;
         }