Browse Source

Merge pull request #34682 from Calinou/os-exit-code-nonportable-warning

Print a warning message if `OS.exit_code` is set to a non-portable value
Rémi Verschelde 5 years ago
parent
commit
ccedda9c71
2 changed files with 5 additions and 1 deletions
  1. 4 0
      core/bind/core_bind.cpp
  2. 1 1
      doc/classes/OS.xml

+ 4 - 0
core/bind/core_bind.cpp

@@ -686,6 +686,10 @@ int _OS::get_exit_code() const {
 
 
 void _OS::set_exit_code(int p_code) {
 void _OS::set_exit_code(int p_code) {
 
 
+	if (p_code < 0 || p_code > 125) {
+		WARN_PRINT("For portability reasons, the exit code should be set between 0 and 125 (inclusive).");
+	}
+
 	OS::get_singleton()->set_exit_code(p_code);
 	OS::get_singleton()->set_exit_code(p_code);
 }
 }
 
 

+ 1 - 1
doc/classes/OS.xml

@@ -905,7 +905,7 @@
 			The current screen index (starting from 0).
 			The current screen index (starting from 0).
 		</member>
 		</member>
 		<member name="exit_code" type="int" setter="set_exit_code" getter="get_exit_code" default="0">
 		<member name="exit_code" type="int" setter="set_exit_code" getter="get_exit_code" default="0">
-			The exit code passed to the OS when the main loop exits.
+			The exit code passed to the OS when the main loop exits. By convention, an exit code of [code]0[/code] indicates success whereas a non-zero exit code indicates an error. For portability reasons, the exit code should be set between 0 and 125 (inclusive).
 		</member>
 		</member>
 		<member name="keep_screen_on" type="bool" setter="set_keep_screen_on" getter="is_keep_screen_on" default="true">
 		<member name="keep_screen_on" type="bool" setter="set_keep_screen_on" getter="is_keep_screen_on" default="true">
 			If [code]true[/code], the engine tries to keep the screen on while the game is running. Useful on mobile.
 			If [code]true[/code], the engine tries to keep the screen on while the game is running. Useful on mobile.