Fix error reporting when a scene is not imported properly, closes #3968

(cherry picked from commit 33f1204dc4)
This commit is contained in:
Juan Linietsky 2016-06-26 15:37:04 -03:00 committed by Rémi Verschelde
parent 9d85bfa00a
commit 9592dd3e3b
3 changed files with 18 additions and 12 deletions

View File

@ -3431,7 +3431,7 @@ void EditorNode::fix_dependencies(const String& p_for_file) {
dependency_fixer->edit(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()) { if (!is_inside_tree()) {
defer_load_scene = p_scene; defer_load_scene = p_scene;
@ -3450,7 +3450,9 @@ Error EditorNode::load_scene(const String& p_scene, bool p_ignore_broken_deps,bo
} }
if (p_clear_errors)
load_errors->clear(); load_errors->clear();
String lpath = Globals::get_singleton()->localize_path(p_scene); String lpath = Globals::get_singleton()->localize_path(p_scene);
if (!lpath.begins_with("res://")) { 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) { void EditorNode::add_io_error(const String& p_error) {
CharString err_ut = p_error.utf8(); //CharString err_ut = p_error.utf8();
ERR_PRINT(err_ut.get_data()); //ERR_PRINT(!err_ut.get_data());
_load_error_notify(singleton,p_error); _load_error_notify(singleton,p_error);
} }
void EditorNode::_load_error_notify(void* p_ud,const String& p_text) { void EditorNode::_load_error_notify(void* p_ud,const String& p_text) {
EditorNode*en=(EditorNode*)p_ud; 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); en->load_error_dialog->popup_centered_ratio(0.5);
} }
@ -6013,8 +6017,9 @@ EditorNode::EditorNode() {
set_process_unhandled_input(true); set_process_unhandled_input(true);
_playing_edited=false; _playing_edited=false;
load_errors = memnew( TextEdit ); Panel *errors = memnew( Panel );
load_errors->set_readonly(true); load_errors = memnew( RichTextLabel );
// load_errors->set_readonly(true);
load_error_dialog = memnew( AcceptDialog ); load_error_dialog = memnew( AcceptDialog );
load_error_dialog->add_child(load_errors); load_error_dialog->add_child(load_errors);
load_error_dialog->set_title("Load Errors"); load_error_dialog->set_title("Load Errors");

View File

@ -255,7 +255,7 @@ class EditorNode : public Node {
TextureProgress *audio_vu; TextureProgress *audio_vu;
//MenuButton *fileserver_menu; //MenuButton *fileserver_menu;
TextEdit *load_errors; RichTextLabel *load_errors;
AcceptDialog *load_error_dialog; AcceptDialog *load_error_dialog;
//Control *scene_root_base; //Control *scene_root_base;
@ -608,7 +608,7 @@ public:
void fix_dependencies(const String& p_for_file); void fix_dependencies(const String& p_for_file);
void clear_scene() { _cleanup_scene(); } 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); Error load_resource(const String& p_scene);
bool is_scene_open(const String& p_path); bool is_scene_open(const String& p_path);

View File

@ -802,7 +802,7 @@ void EditorSceneImportDialog::_import(bool p_and_open) {
return; return;
} }
if (wip_open) 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) 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_open=false;
wip_save_file=""; wip_save_file="";
@ -2740,8 +2740,9 @@ Error EditorSceneImportPlugin::import2(Node *scene, const String& p_dest_path, c
post_import_script = Ref<EditorScenePostImport>( memnew( EditorScenePostImport ) ); post_import_script = Ref<EditorScenePostImport>( memnew( EditorScenePostImport ) );
post_import_script->set_script(scr.get_ref_ptr()); post_import_script->set_script(scr.get_ref_ptr());
if (!post_import_script->get_script_instance()) { 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(); post_import_script.unref();
return ERR_CANT_CREATE;
} }
} }
} }