From dfb11f8cea653a03d1e4f02518721137fe9fdc02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pa=CC=84vels=20Nadtoc=CC=8Cajevs?= <7645683+bruvzg@users.noreply.github.com> Date: Fri, 13 Jun 2025 10:22:31 +0300 Subject: [PATCH] [macOS] Add `--path` argument when instance is created by project started from editor. --- platform/macos/os_macos.mm | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/platform/macos/os_macos.mm b/platform/macos/os_macos.mm index cdaa18f40f6..2bbd3c2c186 100644 --- a/platform/macos/os_macos.mm +++ b/platform/macos/os_macos.mm @@ -825,6 +825,18 @@ Error OS_MacOS::create_instance(const List &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 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);