summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <remi@verschelde.fr>2022-01-14 21:19:34 +0100
committerGitHub <noreply@github.com>2022-01-14 21:19:34 +0100
commitc1e78f749e1adef54265d702d43fd82d773359ea (patch)
treed54dee7be2da737b582826f427bee3f631a457eb
parentcba3d5f34da13d4ca9b8ddca7887758c5c4c285a (diff)
parent18633b975bdc1c6fc8917372767a6bcf74807d0b (diff)
Merge pull request #56706 from KoBeWi/we_need_to_go_higher
-rw-r--r--editor/editor_file_dialog.cpp14
1 files changed, 13 insertions, 1 deletions
diff --git a/editor/editor_file_dialog.cpp b/editor/editor_file_dialog.cpp
index 906205aa19..33c6c77e53 100644
--- a/editor/editor_file_dialog.cpp
+++ b/editor/editor_file_dialog.cpp
@@ -130,6 +130,18 @@ void EditorFileDialog::_notification(int p_what) {
if (!is_visible()) {
set_process_unhandled_input(false);
}
+ } else if (p_what == NOTIFICATION_WM_WINDOW_FOCUS_IN) {
+ // Check if the current directory was removed externally (much less likely to happen while editor window is focused).
+ String previous_dir = get_current_dir();
+ while (!dir_access->dir_exists(get_current_dir())) {
+ _go_up();
+
+ // In case we can't go further up, use some fallback and break.
+ if (get_current_dir() == previous_dir) {
+ _dir_submitted(OS::get_singleton()->get_user_data_dir());
+ break;
+ }
+ }
}
}
@@ -1306,7 +1318,7 @@ void EditorFileDialog::_recent_selected(int p_idx) {
}
void EditorFileDialog::_go_up() {
- dir_access->change_dir("..");
+ dir_access->change_dir(get_current_dir().get_base_dir());
update_file_list();
update_dir();
_push_history();