1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-04 12:00:25 +00:00

[macOS] Add --path argument when instance is created by project started from editor.

This commit is contained in:
Pāvels Nadtočajevs
2025-06-13 10:22:31 +03:00
parent 591e70ff78
commit dfb11f8cea

View File

@@ -825,6 +825,18 @@ Error OS_MacOS::create_instance(const List<String> &p_arguments, ProcessID *r_ch
NSString *nsappname = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleName"];
if (nsappname != nil) {
String path = String::utf8([[[NSBundle mainBundle] bundlePath] UTF8String]);
#ifdef TOOLS_ENABLED
if (Engine::get_singleton() && !Engine::get_singleton()->is_project_manager_hint() && !Engine::get_singleton()->is_editor_hint()) {
// Project started from the editor, inject "path" argument to set instance working directory.
char cwd[PATH_MAX];
if (::getcwd(cwd, sizeof(cwd)) != nullptr) {
List<String> arguments = p_arguments;
arguments.push_back("--path");
arguments.push_back(String::utf8(cwd));
return create_process(path, arguments, r_child_id, false);
}
}
#endif
return create_process(path, p_arguments, r_child_id, false);
} else {
return create_process(get_executable_path(), p_arguments, r_child_id, false);