From 935a56844473931dcd810ae5f6e807f369ac3920 Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Sat, 18 Jun 2016 19:28:33 -0300 Subject: [PATCH] -Do not ask about overwriting when opening a script in the wizard, but still show complaint about existing. Closes #4545 -Fixed a crash in EditorDirDialog --- tools/editor/editor_dir_dialog.cpp | 15 +++++++++++++++ tools/editor/editor_dir_dialog.h | 2 ++ tools/editor/script_create_dialog.cpp | 2 +- 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/tools/editor/editor_dir_dialog.cpp b/tools/editor/editor_dir_dialog.cpp index fda2d9bacf3..a6e231cf186 100644 --- a/tools/editor/editor_dir_dialog.cpp +++ b/tools/editor/editor_dir_dialog.cpp @@ -78,6 +78,11 @@ void EditorDirDialog::_update_dir(TreeItem* p_item) { void EditorDirDialog::reload() { + if (!is_visible()) { + must_reload=true; + return; + } + tree->clear(); TreeItem *root = tree->create_item(); root->set_metadata(0,"res://"); @@ -85,6 +90,8 @@ void EditorDirDialog::reload() { root->set_text(0,"/"); _update_dir(root); _item_collapsed(root); + must_reload=false; + } @@ -96,6 +103,12 @@ void EditorDirDialog::_notification(int p_what) { EditorFileSystem::get_singleton()->connect("filesystem_changed",this,"reload"); } + + if (p_what==NOTIFICATION_VISIBILITY_CHANGED) { + if (must_reload && is_visible()) { + reload(); + } + } } void EditorDirDialog::_item_collapsed(Object* _p_item){ @@ -243,6 +256,8 @@ EditorDirDialog::EditorDirDialog() { get_ok()->set_text(TTR("Choose")); + must_reload=false; + } diff --git a/tools/editor/editor_dir_dialog.h b/tools/editor/editor_dir_dialog.h index 94facceed4d..69f9850c300 100644 --- a/tools/editor/editor_dir_dialog.h +++ b/tools/editor/editor_dir_dialog.h @@ -54,6 +54,8 @@ class EditorDirDialog : public ConfirmationDialog { void ok_pressed(); + bool must_reload; + protected: diff --git a/tools/editor/script_create_dialog.cpp b/tools/editor/script_create_dialog.cpp index e88d603b307..02b94f5ad82 100644 --- a/tools/editor/script_create_dialog.cpp +++ b/tools/editor/script_create_dialog.cpp @@ -184,7 +184,7 @@ void ScriptCreateDialog::_built_in_pressed() { void ScriptCreateDialog::_browse_path() { - file_browse->set_mode(EditorFileDialog::MODE_SAVE_FILE); + file_browse->set_mode(EditorFileDialog::MODE_OPEN_FILE); file_browse->clear_filters(); List extensions;