Merge pull request #61736 from KoBeWi/final_form_of_the_fix

Fix Debugger tab not updating when clearing errors
This commit is contained in:
Fabio Alessandrelli 2022-06-12 20:46:45 +02:00 committed by GitHub
commit ac878ed9b8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 41 additions and 34 deletions

View file

@ -103,6 +103,7 @@ ScriptEditorDebugger *EditorDebuggerNode::_add_debugger() {
node->connect("remote_object_updated", callable_mp(this, &EditorDebuggerNode::_remote_object_updated), varray(id));
node->connect("remote_object_property_updated", callable_mp(this, &EditorDebuggerNode::_remote_object_property_updated), varray(id));
node->connect("remote_object_requested", callable_mp(this, &EditorDebuggerNode::_remote_object_requested), varray(id));
node->connect("errors_cleared", callable_mp(this, &EditorDebuggerNode::_update_errors));
if (tabs->get_tab_count() > 0) {
get_debugger(0)->clear_style();
@ -267,40 +268,7 @@ void EditorDebuggerNode::_notification(int p_what) {
}
server->poll();
// Errors and warnings
int error_count = 0;
int warning_count = 0;
_for_all(tabs, [&](ScriptEditorDebugger *dbg) {
error_count += dbg->get_error_count();
warning_count += dbg->get_warning_count();
});
if (error_count != last_error_count || warning_count != last_warning_count) {
_for_all(tabs, [&](ScriptEditorDebugger *dbg) {
dbg->update_tabs();
});
if (error_count == 0 && warning_count == 0) {
debugger_button->set_text(TTR("Debugger"));
debugger_button->remove_theme_color_override("font_color");
debugger_button->set_icon(Ref<Texture2D>());
} else {
debugger_button->set_text(TTR("Debugger") + " (" + itos(error_count + warning_count) + ")");
if (error_count >= 1 && warning_count >= 1) {
debugger_button->set_icon(get_theme_icon(SNAME("ErrorWarning"), SNAME("EditorIcons")));
// Use error color to represent the highest level of severity reported.
debugger_button->add_theme_color_override("font_color", get_theme_color(SNAME("error_color"), SNAME("Editor")));
} else if (error_count >= 1) {
debugger_button->set_icon(get_theme_icon(SNAME("Error"), SNAME("EditorIcons")));
debugger_button->add_theme_color_override("font_color", get_theme_color(SNAME("error_color"), SNAME("Editor")));
} else {
debugger_button->set_icon(get_theme_icon(SNAME("Warning"), SNAME("EditorIcons")));
debugger_button->add_theme_color_override("font_color", get_theme_color(SNAME("warning_color"), SNAME("Editor")));
}
}
last_error_count = error_count;
last_warning_count = warning_count;
}
_update_errors();
// Remote scene tree update
remote_scene_tree_timeout -= get_process_delta_time();
@ -361,6 +329,42 @@ void EditorDebuggerNode::_notification(int p_what) {
}
}
void EditorDebuggerNode::_update_errors() {
int error_count = 0;
int warning_count = 0;
_for_all(tabs, [&](ScriptEditorDebugger *dbg) {
error_count += dbg->get_error_count();
warning_count += dbg->get_warning_count();
});
if (error_count != last_error_count || warning_count != last_warning_count) {
_for_all(tabs, [&](ScriptEditorDebugger *dbg) {
dbg->update_tabs();
});
if (error_count == 0 && warning_count == 0) {
debugger_button->set_text(TTR("Debugger"));
debugger_button->remove_theme_color_override("font_color");
debugger_button->set_icon(Ref<Texture2D>());
} else {
debugger_button->set_text(TTR("Debugger") + " (" + itos(error_count + warning_count) + ")");
if (error_count >= 1 && warning_count >= 1) {
debugger_button->set_icon(get_theme_icon(SNAME("ErrorWarning"), SNAME("EditorIcons")));
// Use error color to represent the highest level of severity reported.
debugger_button->add_theme_color_override("font_color", get_theme_color(SNAME("error_color"), SNAME("Editor")));
} else if (error_count >= 1) {
debugger_button->set_icon(get_theme_icon(SNAME("Error"), SNAME("EditorIcons")));
debugger_button->add_theme_color_override("font_color", get_theme_color(SNAME("error_color"), SNAME("Editor")));
} else {
debugger_button->set_icon(get_theme_icon(SNAME("Warning"), SNAME("EditorIcons")));
debugger_button->add_theme_color_override("font_color", get_theme_color(SNAME("warning_color"), SNAME("Editor")));
}
}
last_error_count = error_count;
last_warning_count = warning_count;
}
}
void EditorDebuggerNode::_debugger_stopped(int p_id) {
ScriptEditorDebugger *dbg = get_debugger(p_id);
ERR_FAIL_COND(!dbg);

View file

@ -116,6 +116,7 @@ private:
ScriptEditorDebugger *_add_debugger();
EditorDebuggerRemoteObject *get_inspected_remote_object();
void _update_errors();
friend class DebuggerEditorPlugin;
friend class DebugAdapterParser;

View file

@ -1465,6 +1465,7 @@ void ScriptEditorDebugger::_clear_errors_list() {
error_tree->clear();
error_count = 0;
warning_count = 0;
emit_signal(SNAME("errors_cleared"));
update_tabs();
expand_all_button->set_disabled(true);
@ -1626,6 +1627,7 @@ void ScriptEditorDebugger::_bind_methods() {
ADD_SIGNAL(MethodInfo("debug_data", PropertyInfo(Variant::STRING, "msg"), PropertyInfo(Variant::ARRAY, "data")));
ADD_SIGNAL(MethodInfo("set_breakpoint", PropertyInfo("script"), PropertyInfo(Variant::INT, "line"), PropertyInfo(Variant::BOOL, "enabled")));
ADD_SIGNAL(MethodInfo("clear_breakpoints"));
ADD_SIGNAL(MethodInfo("errors_cleared"));
}
void ScriptEditorDebugger::add_debugger_plugin(const Ref<Script> &p_script) {