From 33f1204dc4e919660bd923f366897349a9f9fdbb 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 --- 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 f9bedc76603..c02da178dc4 100644 --- a/tools/editor/editor_node.cpp +++ b/tools/editor/editor_node.cpp @@ -3540,7 +3540,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; @@ -3559,7 +3559,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://")) { @@ -3996,15 +3998,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); } @@ -6421,8 +6425,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(TTR("Load Errors")); diff --git a/tools/editor/editor_node.h b/tools/editor/editor_node.h index bea973a3576..75565118bca 100644 --- a/tools/editor/editor_node.h +++ b/tools/editor/editor_node.h @@ -261,7 +261,7 @@ private: TextureProgress *audio_vu; //MenuButton *fileserver_menu; - TextEdit *load_errors; + RichTextLabel *load_errors; AcceptDialog *load_error_dialog; //Control *scene_root_base; @@ -652,7 +652,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 c7d92a9658b..d5d0fac2b6a 100644 --- a/tools/editor/io_plugins/editor_scene_import_plugin.cpp +++ b/tools/editor/io_plugins/editor_scene_import_plugin.cpp @@ -822,7 +822,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); } @@ -867,7 +867,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=""; @@ -2680,8 +2680,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(TTR("Invalid/broken script for post-import:")+" "+post_import_script_path); + EditorNode::add_io_error(TTR("Invalid/broken script for post-import (check console):")+" "+post_import_script_path); post_import_script.unref(); + return ERR_CANT_CREATE; } } }