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")
{
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()));
}
}