From c733b3aa9787a618a0ce5bb03b3fc731f5663b21 Mon Sep 17 00:00:00 2001 From: Nate Graham Date: Tue, 13 Oct 2020 13:37:11 -0600 Subject: Don't session-restore invalid paths When session restore is populating the main window, it's unconditional; you'll get whatever was there before. This can be a problem if any of those things are now missing. For example, maybe you were browsing files on a removable disk, then quit Dolphin, and finally removed the disk. The next time you launch Dolphin again, it will try to show you the view from the now-missing removable disk. To prevent this, we now look at all the URLs in all of the view containers that were created after session-restore has finished doing its thing; if any of them are invalid local URLs, we change the URL to the home folder instead to avoid showing the user a view with an invalid location in it. BUG: 427619 FIXED-IN: 20.12 --- src/dolphinmainwindow.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/dolphinmainwindow.cpp') diff --git a/src/dolphinmainwindow.cpp b/src/dolphinmainwindow.cpp index 2c91cd07a..f7ec5f511 100644 --- a/src/dolphinmainwindow.cpp +++ b/src/dolphinmainwindow.cpp @@ -216,6 +216,20 @@ QVector DolphinMainWindow::viewContainers() const return viewContainers; } +void DolphinMainWindow::setViewsWithInvalidPathsToHome() +{ + const QVector theViewContainers = viewContainers(); + for (DolphinViewContainer *viewContainer : theViewContainers) { + + // Only consider local dirs, not remote locations and abstract protocols + if (viewContainer->url().isLocalFile()) { + if (!QFileInfo::exists(viewContainer->url().toLocalFile())) { + viewContainer->setUrl(QUrl::fromLocalFile(QDir::homePath())); + } + } + } +} + void DolphinMainWindow::openDirectories(const QList& dirs, bool splitView) { m_tabWidget->openDirectories(dirs, splitView); -- cgit v1.3