Browse Source

Merge pull request #80400 from timothyqiu/eof-debugger

[3.x] Fix infinite loop on EOF in the command line debugger
Rémi Verschelde 2 years ago
parent
commit
9435c38b95
1 changed files with 2 additions and 2 deletions
  1. 2 2
      core/script_debugger_local.cpp

+ 2 - 2
core/script_debugger_local.cpp

@@ -56,7 +56,7 @@ void ScriptDebuggerLocal::debug(ScriptLanguage *p_script, bool p_can_continue, b
 		// Cache options
 		// Cache options
 		String variable_prefix = options["variable_prefix"];
 		String variable_prefix = options["variable_prefix"];
 
 
-		if (line == "") {
+		if (line.empty() && !feof(stdin)) {
 			print_line("\nDebugger Break, Reason: '" + p_script->debug_get_error() + "'");
 			print_line("\nDebugger Break, Reason: '" + p_script->debug_get_error() + "'");
 			print_line("*Frame " + itos(current_frame) + " - " + p_script->debug_get_stack_level_source(current_frame) + ":" + itos(p_script->debug_get_stack_level_line(current_frame)) + " in function '" + p_script->debug_get_stack_level_function(current_frame) + "'");
 			print_line("*Frame " + itos(current_frame) + " - " + p_script->debug_get_stack_level_source(current_frame) + ":" + itos(p_script->debug_get_stack_level_line(current_frame)) + " in function '" + p_script->debug_get_stack_level_function(current_frame) + "'");
 			print_line("Enter \"help\" for assistance.");
 			print_line("Enter \"help\" for assistance.");
@@ -185,7 +185,7 @@ void ScriptDebuggerLocal::debug(ScriptLanguage *p_script, bool p_can_continue, b
 				print_line("Added breakpoint at " + source + ":" + itos(linenr));
 				print_line("Added breakpoint at " + source + ":" + itos(linenr));
 			}
 			}
 
 
-		} else if (line == "q" || line == "quit") {
+		} else if (line == "q" || line == "quit" || (line.empty() && feof(stdin))) {
 			// Do not stop again on quit
 			// Do not stop again on quit
 			clear_breakpoints();
 			clear_breakpoints();
 			ScriptDebugger::get_singleton()->set_depth(-1);
 			ScriptDebugger::get_singleton()->set_depth(-1);