From 9592dd3e3b40bd3e5ad831e68870238cb4aa81e1 Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Sun, 26 Jun 2016 15:37:04 -0300 Subject: [PATCH] Fix error reporting when a scene is not imported properly, closes #3968 (cherry picked from commit 33f1204dc4e919660bd923f366897349a9f9fdbb) --- tools/editor/editor_node.cpp | 19 ++++++++++++------- tools/editor/editor_node.h | 4 ++-- .../io_plugins/editor_scene_import_plugin.cpp | 7 ++++--- 3 files changed, 18 insertions(+), 12 deletions(-) diff --git a/tools/editor/editor_node.cpp b/tools/editor/editor_node.cpp index e1d6582229a..f2242d20519 100644 --- a/tools/editor/editor_node.cpp +++ b/tools/editor/editor_node.cpp @@ -3431,7 +3431,7 @@ void EditorNode::fix_dependencies(const String& p_for_file) { dependency_fixer->edit(p_for_file); } -Error EditorNode::load_scene(const String& p_scene, bool p_ignore_broken_deps,bool p_set_inherited) { +Error EditorNode::load_scene(const String& p_scene, bool p_ignore_broken_deps,bool p_set_inherited,bool p_clear_errors) { if (!is_inside_tree()) { defer_load_scene = p_scene; @@ -3450,7 +3450,9 @@ Error EditorNode::load_scene(const String& p_scene, bool p_ignore_broken_deps,bo } - load_errors->clear(); + if (p_clear_errors) + load_errors->clear(); + String lpath = Globals::get_singleton()->localize_path(p_scene); if (!lpath.begins_with("res://")) { @@ -3890,15 +3892,17 @@ bool EditorNode::_find_editing_changed_scene(Node *p_from) { void EditorNode::add_io_error(const String& p_error) { - CharString err_ut = p_error.utf8(); - ERR_PRINT(err_ut.get_data()); + //CharString err_ut = p_error.utf8(); + //ERR_PRINT(!err_ut.get_data()); _load_error_notify(singleton,p_error); } void EditorNode::_load_error_notify(void* p_ud,const String& p_text) { + EditorNode*en=(EditorNode*)p_ud; - en->load_errors->set_text(en->load_errors->get_text()+p_text+"\n"); + en->load_errors->add_image(en->gui_base->get_icon("Error","EditorIcons")); + en->load_errors->add_text(p_text+"\n"); en->load_error_dialog->popup_centered_ratio(0.5); } @@ -6013,8 +6017,9 @@ EditorNode::EditorNode() { set_process_unhandled_input(true); _playing_edited=false; - load_errors = memnew( TextEdit ); - load_errors->set_readonly(true); + Panel *errors = memnew( Panel ); + load_errors = memnew( RichTextLabel ); +// load_errors->set_readonly(true); load_error_dialog = memnew( AcceptDialog ); load_error_dialog->add_child(load_errors); load_error_dialog->set_title("Load Errors"); diff --git a/tools/editor/editor_node.h b/tools/editor/editor_node.h index 59f53d6cff5..9b7d83dd768 100644 --- a/tools/editor/editor_node.h +++ b/tools/editor/editor_node.h @@ -255,7 +255,7 @@ class EditorNode : public Node { TextureProgress *audio_vu; //MenuButton *fileserver_menu; - TextEdit *load_errors; + RichTextLabel *load_errors; AcceptDialog *load_error_dialog; //Control *scene_root_base; @@ -608,7 +608,7 @@ public: void fix_dependencies(const String& p_for_file); void clear_scene() { _cleanup_scene(); } - Error load_scene(const String& p_scene, bool p_ignore_broken_deps=false, bool p_set_inherited=false); + Error load_scene(const String& p_scene, bool p_ignore_broken_deps=false, bool p_set_inherited=false, bool p_clear_errors=true); Error load_resource(const String& p_scene); bool is_scene_open(const String& p_path); diff --git a/tools/editor/io_plugins/editor_scene_import_plugin.cpp b/tools/editor/io_plugins/editor_scene_import_plugin.cpp index 568fa19c61b..1eda9b36dcc 100644 --- a/tools/editor/io_plugins/editor_scene_import_plugin.cpp +++ b/tools/editor/io_plugins/editor_scene_import_plugin.cpp @@ -802,7 +802,7 @@ void EditorSceneImportDialog::_import(bool p_and_open) { return; } if (wip_open) - EditorNode::get_singleton()->load_scene(save_file); + EditorNode::get_singleton()->load_scene(save_file,false,false,false); } @@ -847,7 +847,7 @@ void EditorSceneImportDialog::_import_confirm() { } if (wip_open) - EditorNode::get_singleton()->load_scene(wip_save_file); + EditorNode::get_singleton()->load_scene(wip_save_file,false,false,false); wip_open=false; wip_save_file=""; @@ -2740,8 +2740,9 @@ Error EditorSceneImportPlugin::import2(Node *scene, const String& p_dest_path, c post_import_script = Ref( memnew( EditorScenePostImport ) ); post_import_script->set_script(scr.get_ref_ptr()); if (!post_import_script->get_script_instance()) { - EditorNode::add_io_error("Invalid/Broken Script for Post-Import: '"+post_import_script_path); + EditorNode::add_io_error("Invalid/broken script for post-import (check console): "+post_import_script_path); post_import_script.unref(); + return ERR_CANT_CREATE; } } }