diff options
Diffstat (limited to 'editor/script_editor_debugger.cpp')
-rw-r--r-- | editor/script_editor_debugger.cpp | 46 |
1 files changed, 39 insertions, 7 deletions
diff --git a/editor/script_editor_debugger.cpp b/editor/script_editor_debugger.cpp index fa0deb7606..86ab84909e 100644 --- a/editor/script_editor_debugger.cpp +++ b/editor/script_editor_debugger.cpp @@ -193,6 +193,12 @@ public: } }; +void ScriptEditorDebugger::debug_copy() { + String msg = reason->get_text(); + if (msg == "") return; + OS::get_singleton()->set_clipboard(msg); +} + void ScriptEditorDebugger::debug_next() { ERR_FAIL_COND(!breaked); @@ -338,6 +344,7 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, const Array &p_da step->set_disabled(!can_continue); next->set_disabled(!can_continue); _set_reason_text(error, MESSAGE_ERROR); + copy->set_disabled(false); breaked = true; dobreak->set_disabled(true); docontinue->set_disabled(false); @@ -354,6 +361,7 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, const Array &p_da } else if (p_msg == "debug_exit") { breaked = false; + copy->set_disabled(true); step->set_disabled(true); next->set_disabled(true); reason->set_text(""); @@ -612,7 +620,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); @@ -938,6 +948,8 @@ void ScriptEditorDebugger::_notification(int p_what) { inspector->edit(variables); + copy->set_icon(get_icon("Duplicate", "EditorIcons")); + step->set_icon(get_icon("DebugStep", "EditorIcons")); next->set_icon(get_icon("DebugNext", "EditorIcons")); back->set_icon(get_icon("Back", "EditorIcons")); @@ -1053,6 +1065,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) { @@ -1117,6 +1131,9 @@ void ScriptEditorDebugger::_notification(int p_what) { break; } } + + if (OS::get_singleton()->get_ticks_msec() > until) + break; } } break; @@ -1166,6 +1183,7 @@ void ScriptEditorDebugger::start() { } set_process(true); + breaked = false; } void ScriptEditorDebugger::pause() { @@ -1177,6 +1195,7 @@ void ScriptEditorDebugger::unpause() { void ScriptEditorDebugger::stop() { set_process(false); + breaked = false; server->stop(); @@ -1609,30 +1628,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) { @@ -1729,6 +1751,9 @@ void ScriptEditorDebugger::_item_menu_id_pressed(int p_option) { void ScriptEditorDebugger::_bind_methods() { ClassDB::bind_method(D_METHOD("_stack_dump_frame_selected"), &ScriptEditorDebugger::_stack_dump_frame_selected); + + ClassDB::bind_method(D_METHOD("debug_copy"), &ScriptEditorDebugger::debug_copy); + ClassDB::bind_method(D_METHOD("debug_next"), &ScriptEditorDebugger::debug_next); ClassDB::bind_method(D_METHOD("debug_step"), &ScriptEditorDebugger::debug_step); ClassDB::bind_method(D_METHOD("debug_break"), &ScriptEditorDebugger::debug_break); @@ -1804,6 +1829,13 @@ ScriptEditorDebugger::ScriptEditorDebugger(EditorNode *p_editor) { hbc->add_child(memnew(VSeparator)); + copy = memnew(ToolButton); + hbc->add_child(copy); + copy->set_tooltip(TTR("Copy Error")); + copy->connect("pressed", this, "debug_copy"); + + hbc->add_child(memnew(VSeparator)); + step = memnew(ToolButton); hbc->add_child(step); step->set_tooltip(TTR("Step Into")); |