From 802ae3518ed755d700fdd83d914a55a8edc2a45a Mon Sep 17 00:00:00 2001 From: Josh Tynjala Date: Fri, 25 Oct 2024 09:13:48 -0700 Subject: [PATCH] System: expand documentation of exit() method Includes explanation that Sys.exit() bypasses Lime's ability to shut down its C++ subsystems, so System.exit() is recommended as best practice instead of Sys.exit(). --- src/lime/system/System.hx | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/lime/system/System.hx b/src/lime/system/System.hx index 039b58283c..71d1812c70 100644 --- a/src/lime/system/System.hx +++ b/src/lime/system/System.hx @@ -191,7 +191,18 @@ class System #if (!lime_doc_gen || sys) /** Attempts to exit the application. Dispatches `onExit`, and will not - exit if the event is canceled. + exit if the event is canceled. When exiting using this method, Lime will + gracefully shut down a number of subsystems, including (but not limited + to) audio, graphics, timers, and game controllers. + + To properly exit a Lime application, it's best to call Lime's + `System.exit()` instead of calling Haxe's built-in `Sys.exit()`. When + targeting native platforms especially, Lime's is built on C++ libraries + that expose functions to clean up resources properly on exit. Haxe's + `Sys.exit()` exits immediately without giving Lime a chance to clean + things up. With that in mind, the proper and correct way to exit a Lime + app is by calling `lime.system.System.exit()`, and to avoid using + `Sys.exit()`. **/ public static function exit(code:Int):Void {