You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-04 12:00:25 +00:00
Merge pull request #106089 from mihe/rogue-newlines
Fix empty lines being added for errors with no script backtrace
This commit is contained in:
@@ -88,7 +88,9 @@ void Logger::log_error(const char *p_function, const char *p_file, int p_line, c
|
||||
logf_error(" at: %s (%s:%i)\n", p_function, p_file, p_line);
|
||||
|
||||
for (const Ref<ScriptBacktrace> &backtrace : p_script_backtraces) {
|
||||
logf_error("%s\n", backtrace->format(3).utf8().get_data());
|
||||
if (!backtrace->is_empty()) {
|
||||
logf_error("%s\n", backtrace->format(3).utf8().get_data());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -52,6 +52,7 @@ void ScriptBacktrace::_store_variables(const List<String> &p_names, const List<V
|
||||
void ScriptBacktrace::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("get_language_name"), &ScriptBacktrace::get_language_name);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("is_empty"), &ScriptBacktrace::is_empty);
|
||||
ClassDB::bind_method(D_METHOD("get_frame_count"), &ScriptBacktrace::get_frame_count);
|
||||
ClassDB::bind_method(D_METHOD("get_frame_function", "index"), &ScriptBacktrace::get_frame_function);
|
||||
ClassDB::bind_method(D_METHOD("get_frame_file", "index"), &ScriptBacktrace::get_frame_file);
|
||||
@@ -173,7 +174,7 @@ Variant ScriptBacktrace::get_member_variable_value(int p_frame_index, int p_vari
|
||||
}
|
||||
|
||||
String ScriptBacktrace::format(int p_indent_all, int p_indent_frames) const {
|
||||
if (stack_frames.is_empty()) {
|
||||
if (is_empty()) {
|
||||
return String();
|
||||
}
|
||||
|
||||
|
||||
@@ -65,6 +65,7 @@ public:
|
||||
|
||||
String get_language_name() const { return language_name; }
|
||||
|
||||
bool is_empty() const { return stack_frames.is_empty(); }
|
||||
int get_frame_count() const { return stack_frames.size(); }
|
||||
String get_frame_function(int p_index) const;
|
||||
String get_frame_file(int p_index) const;
|
||||
|
||||
@@ -124,5 +124,11 @@
|
||||
[b]Warning:[/b] With GDScript backtraces, the returned [Variant] will be the variable's actual value, including any object references. This means that storing the returned [Variant] will prevent any such object from being deallocated, so it's generally recommended not to do so.
|
||||
</description>
|
||||
</method>
|
||||
<method name="is_empty" qualifiers="const">
|
||||
<return type="bool" />
|
||||
<description>
|
||||
Returns [code]true[/code] if the backtrace has no stack frames.
|
||||
</description>
|
||||
</method>
|
||||
</methods>
|
||||
</class>
|
||||
|
||||
@@ -1228,7 +1228,9 @@ void UnixTerminalLogger::log_error(const char *p_function, const char *p_file, i
|
||||
logf_error("%s%sat: %s (%s:%i)%s\n", gray, indent, p_function, p_file, p_line, reset);
|
||||
|
||||
for (const Ref<ScriptBacktrace> &backtrace : p_script_backtraces) {
|
||||
logf_error("%s%s%s\n", gray, backtrace->format(strlen(indent)).utf8().get_data(), reset);
|
||||
if (!backtrace->is_empty()) {
|
||||
logf_error("%s%s%s\n", gray, backtrace->format(strlen(indent)).utf8().get_data(), reset);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -71,7 +71,9 @@ void IOSTerminalLogger::log_error(const char *p_function, const char *p_file, in
|
||||
}
|
||||
|
||||
for (const Ref<ScriptBacktrace> &backtrace : p_script_backtraces) {
|
||||
os_log_error(OS_LOG_DEFAULT, "%{public}s", backtrace->format().utf8().get_data());
|
||||
if (!backtrace->is_empty()) {
|
||||
os_log_error(OS_LOG_DEFAULT, "%{public}s", backtrace->format().utf8().get_data());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -153,7 +153,9 @@ static void handle_crash(int sig) {
|
||||
}
|
||||
if (!script_backtraces.is_empty()) {
|
||||
for (const Ref<ScriptBacktrace> &backtrace : script_backtraces) {
|
||||
print_error(backtrace->format());
|
||||
if (!backtrace->is_empty()) {
|
||||
print_error(backtrace->format());
|
||||
}
|
||||
}
|
||||
print_error("-- END OF SCRIPT BACKTRACE --");
|
||||
print_error("================================================================");
|
||||
|
||||
@@ -183,7 +183,9 @@ static void handle_crash(int sig) {
|
||||
}
|
||||
if (!script_backtraces.is_empty()) {
|
||||
for (const Ref<ScriptBacktrace> &backtrace : script_backtraces) {
|
||||
print_error(backtrace->format());
|
||||
if (!backtrace->is_empty()) {
|
||||
print_error(backtrace->format());
|
||||
}
|
||||
}
|
||||
print_error("-- END OF SCRIPT BACKTRACE --");
|
||||
print_error("================================================================");
|
||||
|
||||
@@ -84,8 +84,10 @@ void MacOSTerminalLogger::log_error(const char *p_function, const char *p_file,
|
||||
}
|
||||
|
||||
for (const Ref<ScriptBacktrace> &backtrace : p_script_backtraces) {
|
||||
os_log_error(OS_LOG_DEFAULT, "%{public}s", backtrace->format().utf8().get_data());
|
||||
logf_error("\E[0;90m%s\E[0m\n", backtrace->format(strlen(indent)).utf8().get_data());
|
||||
if (!backtrace->is_empty()) {
|
||||
os_log_error(OS_LOG_DEFAULT, "%{public}s", backtrace->format().utf8().get_data());
|
||||
logf_error("\E[0;90m%s\E[0m\n", backtrace->format(strlen(indent)).utf8().get_data());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -237,7 +237,9 @@ DWORD CrashHandlerException(EXCEPTION_POINTERS *ep) {
|
||||
}
|
||||
if (!script_backtraces.is_empty()) {
|
||||
for (const Ref<ScriptBacktrace> &backtrace : script_backtraces) {
|
||||
print_error(backtrace->format());
|
||||
if (!backtrace->is_empty()) {
|
||||
print_error(backtrace->format());
|
||||
}
|
||||
}
|
||||
print_error("-- END OF SCRIPT BACKTRACE --");
|
||||
print_error("================================================================");
|
||||
|
||||
@@ -191,7 +191,9 @@ extern void CrashHandlerException(int signal) {
|
||||
}
|
||||
if (!script_backtraces.is_empty()) {
|
||||
for (const Ref<ScriptBacktrace> &backtrace : script_backtraces) {
|
||||
print_error(backtrace->format());
|
||||
if (!backtrace->is_empty()) {
|
||||
print_error(backtrace->format());
|
||||
}
|
||||
}
|
||||
print_error("-- END OF SCRIPT BACKTRACE --");
|
||||
print_error("================================================================");
|
||||
|
||||
@@ -143,7 +143,9 @@ void WindowsTerminalLogger::log_error(const char *p_function, const char *p_file
|
||||
}
|
||||
|
||||
for (const Ref<ScriptBacktrace> &backtrace : p_script_backtraces) {
|
||||
logf_error("%s\n", backtrace->format(strlen(indent)).utf8().get_data());
|
||||
if (!backtrace->is_empty()) {
|
||||
logf_error("%s\n", backtrace->format(strlen(indent)).utf8().get_data());
|
||||
}
|
||||
}
|
||||
|
||||
SetConsoleTextAttribute(hCon, sbi.wAttributes);
|
||||
|
||||
Reference in New Issue
Block a user