Skip to content

Commit

Permalink
Fixed crash when closing the game
Browse files Browse the repository at this point in the history
  • Loading branch information
NeeEoo committed Nov 3, 2023
1 parent af76191 commit 41b5044
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions source/lime/system/System.hx
Original file line number Diff line number Diff line change
Expand Up @@ -141,12 +141,13 @@ class System
#if (!lime_doc_gen || sys)
public static function exit(code:Int):Void
{
#if ((sys || air) && !macro)
if (Application.current != null)
var currentApp = Application.current;
#if ((sys || (js && html5) || air) && !macro)
if (currentApp != null)
{
Application.current.onExit.dispatch(code);
currentApp.onExit.dispatch(code);

if (Application.current.onExit.canceled)
if (currentApp.onExit.canceled)
{
return;
}
Expand All @@ -155,6 +156,11 @@ class System

#if sys
Sys.exit(code);
#elseif (js && html5)
if (currentApp != null && currentApp.window != null)
{
currentApp.window.close();
}
#elseif air
NativeApplication.nativeApplication.exit(code);
#end
Expand Down Expand Up @@ -527,12 +533,11 @@ class System
@:noCompletion private static function __registerEntryPoint(projectName:String, entryPoint:Function):Void
{
// executes first!!

#if sys
funkin.backend.utils.NativeAPI.registerAsDPICompatible();
funkin.backend.system.CommandLineHandler.parseCommandLine(Sys.args());
#end

if (__applicationEntryPoint == null)
{
__applicationEntryPoint = new Map();
Expand Down

2 comments on commit 41b5044

@biomseed
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

my teefs feel weird

@NexIsDumb
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pretty much ironic

Please sign in to comment.