diff options
| author | Vladislav Kachegov <[email protected]> | 2025-05-23 12:46:54 +0300 |
|---|---|---|
| committer | Felix Ernst <[email protected]> | 2025-06-01 00:58:47 +0200 |
| commit | 3e4d9ca10c33746cb545e930886491e6a1227e6e (patch) | |
| tree | 1f6b018feb69c2196ae153fbd6b9d08b94895743 /src/dolphinmainwindow.cpp | |
| parent | 66fcfc24b5d8aa7f09432ecced7b1dc8d6c1dfe1 (diff) | |
fix incorrect view reset when unmounting similarly-named devices
Previously, unmounting a device would incorrectly reset views containing:
- Paths with similar names (e.g. "/media/disk" and "/media/disk_2")
- Substrings of the mounted path
Now only resets views showing either:
1. The exact mounted path (e.g. "/media/disk")
2. Its subdirectories (e.g. "/media/disk/docs")
Diffstat (limited to 'src/dolphinmainwindow.cpp')
| -rw-r--r-- | src/dolphinmainwindow.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/dolphinmainwindow.cpp b/src/dolphinmainwindow.cpp index 297ab000e..2697b12fb 100644 --- a/src/dolphinmainwindow.cpp +++ b/src/dolphinmainwindow.cpp @@ -1726,7 +1726,11 @@ void DolphinMainWindow::setViewsToHomeIfMountPathOpen(const QString &mountPath) { const QVector<DolphinViewContainer *> theViewContainers = viewContainers(); for (DolphinViewContainer *viewContainer : theViewContainers) { - if (viewContainer && viewContainer->url().toLocalFile().startsWith(mountPath)) { + if (!viewContainer) { + continue; + } + const auto viewPath = viewContainer->url().toLocalFile(); + if (viewPath.startsWith(mountPath + QLatin1String("/")) || viewPath == mountPath) { viewContainer->setUrl(QUrl::fromLocalFile(QDir::homePath())); } } |
