From 0b6b8427c81f60f6298491100ceaed3247649539 Mon Sep 17 00:00:00 2001 From: bruvzg <7645683+bruvzg@users.noreply.github.com> Date: Mon, 1 Nov 2021 11:12:52 +0200 Subject: [macOS] Add `create_instance` function to spawn editor copies. [macOS] Modify `create_project` function to detect and run app bundles using NSWorkspace to ensure app window is registered and activated correctly. --- core/core_bind.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'core/core_bind.cpp') diff --git a/core/core_bind.cpp b/core/core_bind.cpp index afd82939ca..b1858c6b32 100644 --- a/core/core_bind.cpp +++ b/core/core_bind.cpp @@ -235,6 +235,19 @@ int OS::execute(const String &p_path, const Vector &p_arguments, Array r return exitcode; } +int OS::create_instance(const Vector &p_arguments) { + List args; + for (int i = 0; i < p_arguments.size(); i++) { + args.push_back(p_arguments[i]); + } + ::OS::ProcessID pid = 0; + Error err = ::OS::get_singleton()->create_instance(args, &pid); + if (err != OK) { + return -1; + } + return pid; +} + int OS::create_process(const String &p_path, const Vector &p_arguments) { List args; for (int i = 0; i < p_arguments.size(); i++) { @@ -537,6 +550,7 @@ void OS::_bind_methods() { ClassDB::bind_method(D_METHOD("get_executable_path"), &OS::get_executable_path); ClassDB::bind_method(D_METHOD("execute", "path", "arguments", "output", "read_stderr"), &OS::execute, DEFVAL(Array()), DEFVAL(false)); ClassDB::bind_method(D_METHOD("create_process", "path", "arguments"), &OS::create_process); + ClassDB::bind_method(D_METHOD("create_instance", "arguments"), &OS::create_instance); ClassDB::bind_method(D_METHOD("kill", "pid"), &OS::kill); ClassDB::bind_method(D_METHOD("shell_open", "uri"), &OS::shell_open); ClassDB::bind_method(D_METHOD("get_process_id"), &OS::get_process_id); -- cgit v1.2.3