Skip to content

Commit f56757d

Browse files
committed
main: Consistently call SDL_SetMainReady() from SDL_RunApp()
`SDL_SetMainReady()` is not a hard requirement on most platforms, but calling it sets up the main thread ID and thus has implications for `SDL_IsMainThread()` for apps that don't use the video subsystem.
1 parent 12f2d21 commit f56757d

File tree

5 files changed

+7
-5
lines changed

5 files changed

+7
-5
lines changed

src/main/SDL_runapp.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ int SDL_RunApp(int argc, char *argv[], SDL_main_func mainFunction, void * reserv
3535
argv = fallbackargv;
3636
}
3737

38+
SDL_SetMainReady();
3839
return mainFunction(argc, argv);
3940
}
4041

src/main/emscripten/SDL_sysmain_runapp.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ int SDL_RunApp(int argc, char *argv[], SDL_main_func mainFunction, void * reserv
6262
}
6363
}, SDL_setenv_unsafe);
6464

65+
SDL_SetMainReady();
6566
return mainFunction(argc, argv);
6667
}
6768

src/main/ps2/SDL_sysmain_runapp.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ int SDL_RunApp(int argc, char *argv[], SDL_main_func mainFunction, void * reserv
6868
{
6969
char fallbackargv0[] = { 'S', 'D', 'L', '_', 'a', 'p', 'p', '\0' };
7070
char *fallbackargv[2] = { fallbackargv0, NULL };
71-
int res;
71+
int result;
7272
(void)reserved;
7373

7474
if (!argv || argc < 0) {
@@ -80,12 +80,11 @@ int SDL_RunApp(int argc, char *argv[], SDL_main_func mainFunction, void * reserv
8080
init_drivers();
8181

8282
SDL_SetMainReady();
83-
84-
res = mainFunction(argc, argv);
83+
result = mainFunction(argc, argv);
8584

8685
deinit_drivers();
8786

88-
return res;
87+
return result;
8988
}
9089

9190
#endif // SDL_PLATFORM_PS2

src/main/psp/SDL_sysmain_runapp.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@ int SDL_RunApp(int argc, char *argv[], SDL_main_func mainFunction, void * reserv
8383
sdl_psp_setup_callbacks();
8484

8585
SDL_SetMainReady();
86-
8786
return mainFunction(argc, argv);
8887
}
8988

src/main/windows/SDL_sysmain_runapp.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ int SDL_RunApp(int caller_argc, char *caller_argv[], SDL_main_func mainFunction,
4343
int result;
4444
(void)reserved;
4545

46+
SDL_SetMainReady();
47+
4648
// If the provided argv is valid, we pass it to the main function as-is, since it's probably what the user wants.
4749
// Otherwise, we take a NULL argv as an instruction for SDL to parse the command line into an argv.
4850
// On Windows, when SDL provides the main entry point, argv is always NULL.

0 commit comments

Comments
 (0)