diff options
Diffstat (limited to 'editor/script_editor_debugger.cpp')
-rw-r--r-- | editor/script_editor_debugger.cpp | 98 |
1 files changed, 88 insertions, 10 deletions
diff --git a/editor/script_editor_debugger.cpp b/editor/script_editor_debugger.cpp index a1c1ec3351..d0527a13ea 100644 --- a/editor/script_editor_debugger.cpp +++ b/editor/script_editor_debugger.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ +/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ @@ -27,6 +27,7 @@ /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ + #include "script_editor_debugger.h" #include "editor_node.h" @@ -611,7 +612,9 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, const Array &p_da if (!EditorNode::get_log()->is_visible()) { if (EditorNode::get_singleton()->are_bottom_panels_hidden()) { - EditorNode::get_singleton()->make_bottom_panel_item_visible(EditorNode::get_log()); + if (EDITOR_GET("run/output/always_open_output_on_play")) { + EditorNode::get_singleton()->make_bottom_panel_item_visible(EditorNode::get_log()); + } } } EditorNode::get_log()->add_message(t); @@ -1052,6 +1055,8 @@ void ScriptEditorDebugger::_notification(int p_what) { break; }; + const uint64_t until = OS::get_singleton()->get_ticks_msec() + 20; + while (ppeer->get_available_packet_count() > 0) { if (pending_in_queue) { @@ -1116,6 +1121,9 @@ void ScriptEditorDebugger::_notification(int p_what) { break; } } + + if (OS::get_singleton()->get_ticks_msec() > until) + break; } } break; @@ -1165,6 +1173,7 @@ void ScriptEditorDebugger::start() { } set_process(true); + breaked = false; } void ScriptEditorDebugger::pause() { @@ -1176,6 +1185,7 @@ void ScriptEditorDebugger::unpause() { void ScriptEditorDebugger::stop() { set_process(false); + breaked = false; server->stop(); @@ -1608,30 +1618,33 @@ void ScriptEditorDebugger::_error_selected(int p_idx) { error_stack->clear(); Array st = error_list->get_item_metadata(p_idx); - for (int i = 0; i < st.size(); i += 2) { + for (int i = 0; i < st.size(); i += 3) { String script = st[i]; - int line = st[i + 1]; + String func = st[i + 1]; + int line = st[i + 2]; Array md; md.push_back(st[i]); md.push_back(st[i + 1]); + md.push_back(st[i + 2]); - String str = script.get_file() + ":" + itos(line); + String str = func + " in " + script.get_file() + ":line " + itos(line); error_stack->add_item(str); error_stack->set_item_metadata(error_stack->get_item_count() - 1, md); - error_stack->set_item_tooltip(error_stack->get_item_count() - 1, TTR("File:") + " " + String(st[i]) + "\n" + TTR("Line:") + " " + itos(line)); + error_stack->set_item_tooltip(error_stack->get_item_count() - 1, + TTR("File:") + " " + script + "\n" + TTR("Function:") + " " + func + "\n" + TTR("Line:") + " " + itos(line)); } } void ScriptEditorDebugger::_error_stack_selected(int p_idx) { Array arr = error_stack->get_item_metadata(p_idx); - if (arr.size() != 2) + if (arr.size() != 3) return; Ref<Script> s = ResourceLoader::load(arr[0]); - emit_signal("goto_script_line", s, int(arr[1]) - 1); + emit_signal("goto_script_line", s, int(arr[2]) - 1); } void ScriptEditorDebugger::set_hide_on_stop(bool p_hide) { @@ -1686,6 +1699,45 @@ void ScriptEditorDebugger::_clear_remote_objects() { remote_objects.clear(); } +void ScriptEditorDebugger::_clear_errors_list() { + + error_list->clear(); + error_count = 0; + _notification(NOTIFICATION_PROCESS); +} + +// Right click on specific file(s) or folder(s). +void ScriptEditorDebugger::_error_list_item_rmb_selected(int p_item, const Vector2 &p_pos) { + + item_menu->clear(); + item_menu->set_size(Size2(1, 1)); + + // Allow specific actions only on one item. + bool single_item_selected = error_list->get_selected_items().size() == 1; + + if (single_item_selected) { + item_menu->add_icon_item(get_icon("CopyNodePath", "EditorIcons"), TTR("Copy Error"), ITEM_MENU_COPY_ERROR); + } + + if (item_menu->get_item_count() > 0) { + item_menu->set_position(error_list->get_global_position() + p_pos); + item_menu->popup(); + } +} + +void ScriptEditorDebugger::_item_menu_id_pressed(int p_option) { + + switch (p_option) { + + case ITEM_MENU_COPY_ERROR: { + String title = error_list->get_item_text(error_list->get_current()); + String desc = error_list->get_item_tooltip(error_list->get_current()); + + OS::get_singleton()->set_clipboard(title + "\n----------\n" + desc); + } break; + } +} + void ScriptEditorDebugger::_bind_methods() { ClassDB::bind_method(D_METHOD("_stack_dump_frame_selected"), &ScriptEditorDebugger::_stack_dump_frame_selected); @@ -1705,6 +1757,10 @@ void ScriptEditorDebugger::_bind_methods() { ClassDB::bind_method(D_METHOD("_error_stack_selected"), &ScriptEditorDebugger::_error_stack_selected); ClassDB::bind_method(D_METHOD("_profiler_activate"), &ScriptEditorDebugger::_profiler_activate); ClassDB::bind_method(D_METHOD("_profiler_seeked"), &ScriptEditorDebugger::_profiler_seeked); + ClassDB::bind_method(D_METHOD("_clear_errors_list"), &ScriptEditorDebugger::_clear_errors_list); + + ClassDB::bind_method(D_METHOD("_error_list_item_rmb_selected"), &ScriptEditorDebugger::_error_list_item_rmb_selected); + ClassDB::bind_method(D_METHOD("_item_menu_id_pressed"), &ScriptEditorDebugger::_item_menu_id_pressed); ClassDB::bind_method(D_METHOD("_paused"), &ScriptEditorDebugger::_paused); @@ -1829,9 +1885,31 @@ ScriptEditorDebugger::ScriptEditorDebugger(EditorNode *p_editor) { error_split = memnew(HSplitContainer); VBoxContainer *errvb = memnew(VBoxContainer); + HBoxContainer *errhb = memnew(HBoxContainer); errvb->set_h_size_flags(SIZE_EXPAND_FILL); + Label *velb = memnew(Label(TTR("Errors:"))); + velb->set_h_size_flags(SIZE_EXPAND_FILL); + errhb->add_child(velb); + + clearbutton = memnew(Button); + clearbutton->set_text(TTR("Clear")); + clearbutton->connect("pressed", this, "_clear_errors_list"); + errhb->add_child(clearbutton); + errvb->add_child(errhb); + error_list = memnew(ItemList); - errvb->add_margin_child(TTR("Errors:"), error_list, true); + error_list->set_v_size_flags(SIZE_EXPAND_FILL); + error_list->set_h_size_flags(SIZE_EXPAND_FILL); + error_list->connect("item_rmb_selected", this, "_error_list_item_rmb_selected"); + error_list->set_allow_rmb_select(true); + error_list->set_autoscroll_to_bottom(true); + + item_menu = memnew(PopupMenu); + item_menu->connect("id_pressed", this, "_item_menu_id_pressed"); + error_list->add_child(item_menu); + + errvb->add_child(error_list); + error_split->add_child(errvb); errvb = memnew(VBoxContainer); |