diff options
author | Fabio Alessandrelli <fabio.alessandrelli@gmail.com> | 2020-02-07 02:52:05 +0100 |
---|---|---|
committer | Fabio Alessandrelli <fabio.alessandrelli@gmail.com> | 2020-02-21 11:12:03 +0100 |
commit | cbc450c0e53dbfc31a30f5ebf37c51cee77cde5c (patch) | |
tree | fa1e7a1e80ec7cbe0546a752732bf34b66299100 /editor/editor_run.cpp | |
parent | 8b058d4b9a63799e29d3e9ef551bbdf8144f8f8b (diff) |
Huge Debugger/EditorDebugger refactor.
Diffstat (limited to 'editor/editor_run.cpp')
-rw-r--r-- | editor/editor_run.cpp | 32 |
1 files changed, 26 insertions, 6 deletions
diff --git a/editor/editor_run.cpp b/editor/editor_run.cpp index ff7420e19b..3200a0ac8b 100644 --- a/editor/editor_run.cpp +++ b/editor/editor_run.cpp @@ -38,7 +38,7 @@ EditorRun::Status EditorRun::get_status() const { return status; } -Error EditorRun::run(const String &p_scene, const String &p_custom_args, const List<String> &p_breakpoints, const bool &p_skip_breakpoints) { +Error EditorRun::run(const String &p_scene, const String &p_custom_args, const List<String> &p_breakpoints, const bool &p_skip_breakpoints, const int &p_instances) { List<String> args; @@ -187,20 +187,40 @@ Error EditorRun::run(const String &p_scene, const String &p_custom_args, const L }; printf("\n"); - pid = 0; - Error err = OS::get_singleton()->execute(exec, args, false, &pid); - ERR_FAIL_COND_V(err, err); + for (int i = 0; i < p_instances; i++) { + OS::ProcessID pid = 0; + Error err = OS::get_singleton()->execute(exec, args, false, &pid); + ERR_FAIL_COND_V(err, err); + pids.push_back(pid); + } status = STATUS_PLAY; return OK; } +bool EditorRun::has_child_process(OS::ProcessID p_pid) const { + for (const List<OS::ProcessID>::Element *E = pids.front(); E; E = E->next()) { + if (E->get() == p_pid) + return true; + } + return false; +} + +void EditorRun::stop_child_process(OS::ProcessID p_pid) { + if (has_child_process(p_pid)) { + OS::get_singleton()->kill(p_pid); + pids.erase(p_pid); + } +} + void EditorRun::stop() { - if (status != STATUS_STOP && pid != 0) { + if (status != STATUS_STOP && pids.size() > 0) { - OS::get_singleton()->kill(pid); + for (List<OS::ProcessID>::Element *E = pids.front(); E; E = E->next()) { + OS::get_singleton()->kill(E->get()); + } } status = STATUS_STOP; |