Browse Source

Fix file list in FileDialog not updating on first run

Rindbee 3 years ago
parent
commit
88b72c3de4
2 changed files with 8 additions and 18 deletions
  1. 6 14
      editor/editor_file_dialog.cpp
  2. 2 4
      scene/gui/file_dialog.cpp

+ 6 - 14
editor/editor_file_dialog.cpp

@@ -145,6 +145,8 @@ void EditorFileDialog::_notification(int p_what) {
 			if (!is_visible()) {
 			if (!is_visible()) {
 				set_process_shortcut_input(false);
 				set_process_shortcut_input(false);
 			}
 			}
+
+			invalidate(); // For consistency with the standard FileDialog.
 		} break;
 		} break;
 
 
 		case NOTIFICATION_WM_WINDOW_FOCUS_IN: {
 		case NOTIFICATION_WM_WINDOW_FOCUS_IN: {
@@ -304,10 +306,6 @@ void EditorFileDialog::_post_popup() {
 	}
 	}
 	set_current_dir(current);
 	set_current_dir(current);
 
 
-	if (invalidated) {
-		update_file_list();
-		invalidated = false;
-	}
 	if (mode == FILE_MODE_SAVE_FILE) {
 	if (mode == FILE_MODE_SAVE_FILE) {
 		file->grab_focus();
 		file->grab_focus();
 	} else {
 	} else {
@@ -320,19 +318,13 @@ void EditorFileDialog::_post_popup() {
 		file_box->set_visible(true);
 		file_box->set_visible(true);
 	}
 	}
 
 
-	if (is_visible() && !get_current_file().is_empty()) {
+	if (!get_current_file().is_empty()) {
 		_request_single_thumbnail(get_current_dir().path_join(get_current_file()));
 		_request_single_thumbnail(get_current_dir().path_join(get_current_file()));
 	}
 	}
 
 
-	if (is_visible()) {
-		_update_recent();
-
-		local_history.clear();
-		local_history_pos = -1;
-		_push_history();
-
-		_update_favorites();
-	}
+	local_history.clear();
+	local_history_pos = -1;
+	_push_history();
 
 
 	set_process_shortcut_input(true);
 	set_process_shortcut_input(true);
 }
 }

+ 2 - 4
scene/gui/file_dialog.cpp

@@ -87,6 +87,8 @@ void FileDialog::_notification(int p_what) {
 			if (!is_visible()) {
 			if (!is_visible()) {
 				set_process_shortcut_input(false);
 				set_process_shortcut_input(false);
 			}
 			}
+
+			invalidate(); // Put it here to preview in the editor.
 		} break;
 		} break;
 
 
 		case NOTIFICATION_THEME_CHANGED: {
 		case NOTIFICATION_THEME_CHANGED: {
@@ -223,10 +225,6 @@ void FileDialog::_save_confirm_pressed() {
 
 
 void FileDialog::_post_popup() {
 void FileDialog::_post_popup() {
 	ConfirmationDialog::_post_popup();
 	ConfirmationDialog::_post_popup();
-	if (invalidated) {
-		update_file_list();
-		invalidated = false;
-	}
 	if (mode == FILE_MODE_SAVE_FILE) {
 	if (mode == FILE_MODE_SAVE_FILE) {
 		file->grab_focus();
 		file->grab_focus();
 	} else {
 	} else {