Skip to content

Commit 2aab160

Browse files
committed
Merge pull request #107479 from bruvzg/macos_ed_inst_cwd
[macOS] Add `--path` argument when instance is created by project started from editor.
2 parents 3b2b015 + dfb11f8 commit 2aab160

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

platform/macos/os_macos.mm

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -825,6 +825,18 @@
825825
NSString *nsappname = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleName"];
826826
if (nsappname != nil) {
827827
String path = String::utf8([[[NSBundle mainBundle] bundlePath] UTF8String]);
828+
#ifdef TOOLS_ENABLED
829+
if (Engine::get_singleton() && !Engine::get_singleton()->is_project_manager_hint() && !Engine::get_singleton()->is_editor_hint()) {
830+
// Project started from the editor, inject "path" argument to set instance working directory.
831+
char cwd[PATH_MAX];
832+
if (::getcwd(cwd, sizeof(cwd)) != nullptr) {
833+
List<String> arguments = p_arguments;
834+
arguments.push_back("--path");
835+
arguments.push_back(String::utf8(cwd));
836+
return create_process(path, arguments, r_child_id, false);
837+
}
838+
}
839+
#endif
828840
return create_process(path, p_arguments, r_child_id, false);
829841
} else {
830842
return create_process(get_executable_path(), p_arguments, r_child_id, false);

0 commit comments

Comments
 (0)