Right now, when you unmount a device that any active view containers are
displaying, nothing in the view changes. As a result, it's possible to
try to navigate to files or folders in that view, which cannot be done
because the disk that the files or folders are located on has been
unmounted!
With this commit, we detect that case and switch the view containers
to show the home folder after the disk whose contents they are displaying
gets unmounted.
BUG: 158934
FIXED-IN: 20.12
void DolphinMainWindow::slotStorageTearDownFromPlacesRequested(const QString& mountPath)
{
void DolphinMainWindow::slotStorageTearDownFromPlacesRequested(const QString& mountPath)
{
+ connect(m_placesPanel, &PlacesPanel::storageTearDownSuccessful, this, [this, mountPath]() {
+ setViewsToHomeIfMountPathOpen(mountPath);
+ });
+
if (m_terminalPanel && m_terminalPanel->currentWorkingDirectory().startsWith(mountPath)) {
m_tearDownFromPlacesRequested = true;
m_terminalPanel->goHome();
if (m_terminalPanel && m_terminalPanel->currentWorkingDirectory().startsWith(mountPath)) {
m_tearDownFromPlacesRequested = true;
m_terminalPanel->goHome();
void DolphinMainWindow::slotStorageTearDownExternallyRequested(const QString& mountPath)
{
void DolphinMainWindow::slotStorageTearDownExternallyRequested(const QString& mountPath)
{
+ connect(m_placesPanel, &PlacesPanel::storageTearDownSuccessful, this, [this, mountPath]() {
+ setViewsToHomeIfMountPathOpen(mountPath);
+ });
+
if (m_terminalPanel && m_terminalPanel->currentWorkingDirectory().startsWith(mountPath)) {
m_tearDownFromPlacesRequested = false;
m_terminalPanel->goHome();
}
}
if (m_terminalPanel && m_terminalPanel->currentWorkingDirectory().startsWith(mountPath)) {
m_tearDownFromPlacesRequested = false;
m_terminalPanel->goHome();
}
}
+void DolphinMainWindow::setViewsToHomeIfMountPathOpen(const QString& mountPath)
+{
+ const QVector<DolphinViewContainer*> theViewContainers = viewContainers();
+ for (DolphinViewContainer *viewContainer : theViewContainers) {
+ if (viewContainer && viewContainer->url().toLocalFile().startsWith(mountPath)) {
+ viewContainer->setUrl(QUrl::fromLocalFile(QDir::homePath()));
+ }
+ }
+ disconnect(m_placesPanel, &PlacesPanel::storageTearDownSuccessful, nullptr, nullptr);
+}
+
void DolphinMainWindow::setupActions()
{
// setup 'File' menu
void DolphinMainWindow::setupActions()
{
// setup 'File' menu
*/
KNewFileMenu* newFileMenu() const;
*/
KNewFileMenu* newFileMenu() const;
- void setTabsToHomeIfMountPathOpen(const QString& mountPath);
+ /**
+ * Switch the window's view containers' locations to display the home path
+ * for any which are currently displaying a location corresponding to or
+ * within mountPath.
+ *
+ * This typically done after unmounting a disk at mountPath to ensure that
+ * the window is not displaying an invalid location.
+ */
+ void setViewsToHomeIfMountPathOpen(const QString& mountPath);
} else {
emit errorMessage(errorData.toString());
}
} else {
emit errorMessage(errorData.toString());
}
+ } else {
+ // No error; it must have been unmounted successfully
+ emit storageTearDownSuccessful();
}
disconnect(m_deviceToTearDown, &Solid::StorageAccess::teardownDone,
this, &PlacesItemModel::slotStorageTearDownDone);
}
disconnect(m_deviceToTearDown, &Solid::StorageAccess::teardownDone,
this, &PlacesItemModel::slotStorageTearDownDone);
void storageSetupDone(int index, bool success);
void storageTearDownRequested(const QString& mountPath);
void storageTearDownExternallyRequested(const QString& mountPath);
void storageSetupDone(int index, bool success);
void storageTearDownRequested(const QString& mountPath);
void storageTearDownExternallyRequested(const QString& mountPath);
+ void storageTearDownSuccessful();
protected:
void onItemInserted(int index) override;
protected:
void onItemInserted(int index) override;
this, &PlacesPanel::storageTearDownRequested);
connect(m_model, &PlacesItemModel::storageTearDownExternallyRequested,
this, &PlacesPanel::storageTearDownExternallyRequested);
this, &PlacesPanel::storageTearDownRequested);
connect(m_model, &PlacesItemModel::storageTearDownExternallyRequested,
this, &PlacesPanel::storageTearDownExternallyRequested);
+ connect(m_model, &PlacesItemModel::storageTearDownSuccessful,
+ this, &PlacesPanel::storageTearDownSuccessful);
m_view = new PlacesView();
m_view->setWidgetCreator(new KItemListWidgetCreator<PlacesItemListWidget>());
m_view = new PlacesView();
m_view->setWidgetCreator(new KItemListWidgetCreator<PlacesItemListWidget>());
void storageTearDownRequested(const QString& mountPath);
void storageTearDownExternallyRequested(const QString& mountPath);
void showHiddenEntriesChanged(bool shown);
void storageTearDownRequested(const QString& mountPath);
void storageTearDownExternallyRequested(const QString& mountPath);
void showHiddenEntriesChanged(bool shown);
+ void storageTearDownSuccessful();
protected:
bool urlChanged() override;
protected:
bool urlChanged() override;