Skip to content

Commit 0beabc3

Browse files
SiegeLordExSiegeLord
authored andcommitted
Use a different mechanism for passing the user main to al_run_main.
This one doesn't crash on MacOS when using bundles. Fixes #56
1 parent 54ce16e commit 0beabc3

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

allegro5/system.d

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ extern (C) void rt_moduleTlsDtor();
1313

1414
int al_run_allegro(scope int delegate() user_main)
1515
{
16+
__gshared int delegate() user_main_inner;
17+
user_main_inner = user_main;
1618
extern(C) static int main_runner(int argc, char** argv)
1719
{
1820
version(OSX)
@@ -21,7 +23,7 @@ int al_run_allegro(scope int delegate() user_main)
2123
rt_moduleTlsCtor();
2224
}
2325

24-
auto main_ret = (*cast(int delegate()*)argv[0])();
26+
auto main_ret = user_main_inner();
2527

2628
version(OSX)
2729
{
@@ -32,8 +34,7 @@ int al_run_allegro(scope int delegate() user_main)
3234
return main_ret;
3335
}
3436

35-
char* fake_arg = cast(char*)&user_main;
36-
return al_run_main(0, &fake_arg, &main_runner);
37+
return al_run_main(0, null, &main_runner);
3738
}
3839

3940
nothrow @nogc extern (C)

0 commit comments

Comments
 (0)