mirror of
https://github.com/godotengine/godot.git
synced 2025-12-08 06:09:55 +00:00
[macOS] Do not use NSApplication main loop for headless mode.
This commit is contained in:
parent
7826b6b13f
commit
8b045ca8fe
3 changed files with 69 additions and 0 deletions
|
|
@ -1171,6 +1171,59 @@ OS_MacOS_NSApp::OS_MacOS_NSApp(const char *p_execpath, int p_argc, char **p_argv
|
|||
sigaction(SIGINT, &action, nullptr);
|
||||
}
|
||||
|
||||
// MARK: - OS_MacOS_Headless
|
||||
|
||||
void OS_MacOS_Headless::run() {
|
||||
CFRunLoopGetCurrent();
|
||||
|
||||
@autoreleasepool {
|
||||
Error err = Main::setup(execpath, argc, argv);
|
||||
if (err != OK) {
|
||||
if (err == ERR_HELP) {
|
||||
return set_exit_code(EXIT_SUCCESS);
|
||||
}
|
||||
return set_exit_code(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
|
||||
int ret;
|
||||
@autoreleasepool {
|
||||
ret = Main::start();
|
||||
}
|
||||
|
||||
if (ret == EXIT_SUCCESS && main_loop) {
|
||||
@autoreleasepool {
|
||||
main_loop->initialize();
|
||||
}
|
||||
|
||||
while (true) {
|
||||
@autoreleasepool {
|
||||
@try {
|
||||
if (Input::get_singleton()) {
|
||||
Input::get_singleton()->flush_buffered_events();
|
||||
}
|
||||
|
||||
if (Main::iteration()) {
|
||||
break;
|
||||
}
|
||||
|
||||
CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0, 0);
|
||||
} @catch (NSException *exception) {
|
||||
ERR_PRINT("NSException: " + String::utf8([exception reason].UTF8String));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
main_loop->finalize();
|
||||
}
|
||||
|
||||
Main::cleanup();
|
||||
}
|
||||
|
||||
OS_MacOS_Headless::OS_MacOS_Headless(const char *p_execpath, int p_argc, char **p_argv) :
|
||||
OS_MacOS(p_execpath, p_argc, p_argv) {
|
||||
}
|
||||
|
||||
// MARK: - OS_MacOS_Embedded
|
||||
|
||||
#ifdef DEBUG_ENABLED
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue