┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNate Graham <[email protected]>2020-10-13 13:37:11 -0600
committerElvis Angelaccio <[email protected]>2020-10-23 17:00:09 +0000
commitc733b3aa9787a618a0ce5bb03b3fc731f5663b21 (patch)
treefdf7c83754186caa2c489e1b8d1959e8101ec952 /src
parentae1d441dacef7e52984201abdc9a918ce060021c (diff)
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
Diffstat (limited to 'src')
-rw-r--r--src/dolphinmainwindow.cpp14
-rw-r--r--src/dolphinmainwindow.h6
-rw-r--r--src/main.cpp4
3 files changed, 24 insertions, 0 deletions
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<DolphinViewContainer*> DolphinMainWindow::viewContainers() const
return viewContainers;
}
+void DolphinMainWindow::setViewsWithInvalidPathsToHome()
+{
+ const QVector<DolphinViewContainer*> 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<QUrl>& dirs, bool splitView)
{
m_tabWidget->openDirectories(dirs, splitView);
diff --git a/src/dolphinmainwindow.h b/src/dolphinmainwindow.h
index 80d0f891a..faf428c03 100644
--- a/src/dolphinmainwindow.h
+++ b/src/dolphinmainwindow.h
@@ -102,6 +102,12 @@ public:
*/
void setViewsToHomeIfMountPathOpen(const QString& mountPath);
+ /**
+ * Sets any of the window's view containers which are currently displaying
+ * invalid locations to the home path
+ */
+ void setViewsWithInvalidPathsToHome();
+
public slots:
/**
* Opens each directory in \p dirs in a separate tab. If \a splitView is set,
diff --git a/src/main.cpp b/src/main.cpp
index 0a252bc77..9191127e5 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -191,6 +191,10 @@ extern "C" Q_DECL_EXPORT int kdemain(int argc, char **argv)
if (startedWithURLs) {
mainWindow->openDirectories(urls, splitView);
}
+
+ // Now handle invalid locations in the set of active views to
+ // avoid issues like https://bugs.kde.org/show_bug.cgi?id=427619
+ mainWindow->setViewsWithInvalidPathsToHome();
} else {
qCWarning(DolphinDebug) << "Unknown class " << className << " in session saved data!";
}