Fix #16543 (add button to copy error from debugger)

This commit is contained in:
Artem Varaksa 2018-02-13 19:46:45 +03:00
parent 8cfe798877
commit b169b16f98
2 changed files with 23 additions and 0 deletions

View File

@ -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() { void ScriptEditorDebugger::debug_next() {
ERR_FAIL_COND(!breaked); 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); step->set_disabled(!can_continue);
next->set_disabled(!can_continue); next->set_disabled(!can_continue);
_set_reason_text(error, MESSAGE_ERROR); _set_reason_text(error, MESSAGE_ERROR);
copy->set_disabled(false);
breaked = true; breaked = true;
dobreak->set_disabled(true); dobreak->set_disabled(true);
docontinue->set_disabled(false); 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") { } else if (p_msg == "debug_exit") {
breaked = false; breaked = false;
copy->set_disabled(true);
step->set_disabled(true); step->set_disabled(true);
next->set_disabled(true); next->set_disabled(true);
reason->set_text(""); reason->set_text("");
@ -940,6 +948,8 @@ void ScriptEditorDebugger::_notification(int p_what) {
inspector->edit(variables); inspector->edit(variables);
copy->set_icon(get_icon("Duplicate", "EditorIcons"));
step->set_icon(get_icon("DebugStep", "EditorIcons")); step->set_icon(get_icon("DebugStep", "EditorIcons"));
next->set_icon(get_icon("DebugNext", "EditorIcons")); next->set_icon(get_icon("DebugNext", "EditorIcons"));
back->set_icon(get_icon("Back", "EditorIcons")); back->set_icon(get_icon("Back", "EditorIcons"));
@ -1741,6 +1751,9 @@ void ScriptEditorDebugger::_item_menu_id_pressed(int p_option) {
void ScriptEditorDebugger::_bind_methods() { void ScriptEditorDebugger::_bind_methods() {
ClassDB::bind_method(D_METHOD("_stack_dump_frame_selected"), &ScriptEditorDebugger::_stack_dump_frame_selected); 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_next"), &ScriptEditorDebugger::debug_next);
ClassDB::bind_method(D_METHOD("debug_step"), &ScriptEditorDebugger::debug_step); ClassDB::bind_method(D_METHOD("debug_step"), &ScriptEditorDebugger::debug_step);
ClassDB::bind_method(D_METHOD("debug_break"), &ScriptEditorDebugger::debug_break); ClassDB::bind_method(D_METHOD("debug_break"), &ScriptEditorDebugger::debug_break);
@ -1816,6 +1829,13 @@ ScriptEditorDebugger::ScriptEditorDebugger(EditorNode *p_editor) {
hbc->add_child(memnew(VSeparator)); 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); step = memnew(ToolButton);
hbc->add_child(step); hbc->add_child(step);
step->set_tooltip(TTR("Step Into")); step->set_tooltip(TTR("Step Into"));

View File

@ -104,6 +104,7 @@ class ScriptEditorDebugger : public Control {
Label *reason; Label *reason;
Button *copy;
Button *step; Button *step;
Button *next; Button *next;
Button *back; Button *back;
@ -197,6 +198,8 @@ public:
void unpause(); void unpause();
void stop(); void stop();
void debug_copy();
void debug_next(); void debug_next();
void debug_step(); void debug_step();
void debug_break(); void debug_break();