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
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;
}