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

This commit is contained in:
Juan Linietsky 2016-06-26 15:37:04 -03:00
parent 66d513bb2a
commit 33f1204dc4
3 changed files with 18 additions and 12 deletions

View File

@ -3540,7 +3540,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;
@ -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); String lpath = Globals::get_singleton()->localize_path(p_scene);
if (!lpath.begins_with("res://")) { 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) { 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);
} }
@ -6421,8 +6425,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(TTR("Load Errors")); load_error_dialog->set_title(TTR("Load Errors"));

View File

@ -261,7 +261,7 @@ private:
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;
@ -652,7 +652,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

@ -822,7 +822,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);
} }
@ -867,7 +867,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="";
@ -2680,8 +2680,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(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(); post_import_script.unref();
return ERR_CANT_CREATE;
} }
} }
} }