diff options
author | kobewi <kobewi4e@gmail.com> | 2022-01-12 00:53:52 +0100 |
---|---|---|
committer | kobewi <kobewi4e@gmail.com> | 2022-01-12 12:46:37 +0100 |
commit | 18633b975bdc1c6fc8917372767a6bcf74807d0b (patch) | |
tree | d2a0a32c54b7422178ab57536c7863867b0f0b5c /editor | |
parent | 96a20e477b8cf2760dacab830ba7807c6f61bb8d (diff) |
Automatically go up if current dir was deleted
Diffstat (limited to 'editor')
-rw-r--r-- | editor/editor_file_dialog.cpp | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/editor/editor_file_dialog.cpp b/editor/editor_file_dialog.cpp index dee00b6678..5fbd16e92d 100644 --- a/editor/editor_file_dialog.cpp +++ b/editor/editor_file_dialog.cpp @@ -121,6 +121,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; + } + } } } @@ -1301,7 +1313,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(); |