]> cloud.milkyroute.net Git - dolphin.git/commitdiff
DolphinViewContainer: Delay changing the url
authorAmol Godbole <amolagodbole@gmail.com>
Sun, 15 Sep 2024 23:49:43 +0000 (18:49 -0500)
committerMéven Car <meven@kde.org>
Tue, 8 Oct 2024 09:15:38 +0000 (09:15 +0000)
KCoreDirLister::itemsDeleted() signal is being emitted twice for the
same url. This results in Dolphin displaying an incorrect location.
Delay changing the url instead of delaying
DolphinView::currentDirectoryRemoved() so that the check for current
directory being removed in KFileItemModel::slotItemsDeleted() occurs
correctly, while still ensuring that KCoreDirLister is not prematurely
modified.

BUG: 492277, BUG: 473377

src/dolphinviewcontainer.cpp
src/views/dolphinview.cpp

index e55519d04300b270967fcf744b026907d5f76e21..c89621dbd616dbe67a579a64aba7425989c4bfd3 100644 (file)
@@ -975,10 +975,13 @@ void DolphinViewContainer::slotCurrentDirectoryRemoved()
         const QString dirPath = url().toLocalFile();
         const QString newPath = getNearestExistingAncestorOfPath(dirPath);
         const QUrl newUrl = QUrl::fromLocalFile(newPath);
-        setUrl(newUrl);
-    }
-
-    showMessage(xi18n("Current location changed, <filename>%1</filename> is no longer accessible.", location), KMessageWidget::Warning);
+        // #473377: Delay changing the url to avoid modifying KCoreDirLister before KCoreDirListerCache::deleteDir() returns.
+        QTimer::singleShot(0, this, [&, newUrl, location] {
+            setUrl(newUrl);
+            showMessage(xi18n("Current location changed, <filename>%1</filename> is no longer accessible.", location), KMessageWidget::Warning);
+        });
+    } else
+        showMessage(xi18n("Current location changed, <filename>%1</filename> is no longer accessible.", location), KMessageWidget::Warning);
 }
 
 void DolphinViewContainer::slotOpenUrlFinished(KJob *job)
index 11c0423bee6954670c74c7fd6d3d22f65cbd0bfe..9d6a449c9fa5ea2f6336028237c3591a0381c1c6 100644 (file)
@@ -199,8 +199,7 @@ DolphinView::DolphinView(const QUrl &url, QWidget *parent)
     connect(m_model, &KFileItemModel::directoryRedirection, this, &DolphinView::slotDirectoryRedirection);
     connect(m_model, &KFileItemModel::urlIsFileError, this, &DolphinView::urlIsFileError);
     connect(m_model, &KFileItemModel::fileItemsChanged, this, &DolphinView::fileItemsChanged);
-    // #473377: Use a QueuedConnection to avoid modifying KCoreDirLister before KCoreDirListerCache::deleteDir() returns.
-    connect(m_model, &KFileItemModel::currentDirectoryRemoved, this, &DolphinView::currentDirectoryRemoved, Qt::QueuedConnection);
+    connect(m_model, &KFileItemModel::currentDirectoryRemoved, this, &DolphinView::currentDirectoryRemoved);
 
     connect(this, &DolphinView::itemCountChanged, this, &DolphinView::updatePlaceholderLabel);