Merge pull request #37067 from zaksnet/multiple-editor-instances
Automatic remote debugger port assignment.
This commit is contained in:
commit
48cc756f88
4 changed files with 40 additions and 11 deletions
|
@ -2250,16 +2250,16 @@ void EditorNode::_run(bool p_current, const String &p_custom) {
|
|||
|
||||
args = ProjectSettings::get_singleton()->get("editor/main_run_args");
|
||||
skip_breakpoints = ScriptEditor::get_singleton()->get_debugger()->is_skip_breakpoints();
|
||||
emit_signal("play_pressed");
|
||||
|
||||
Error error = editor_run.run(run_filename, args, breakpoints, skip_breakpoints);
|
||||
|
||||
if (error != OK) {
|
||||
|
||||
emit_signal("stop_pressed");
|
||||
show_accept(TTR("Could not start subprocess!"), TTR("OK"));
|
||||
return;
|
||||
}
|
||||
|
||||
emit_signal("play_pressed");
|
||||
if (p_current) {
|
||||
play_scene_button->set_pressed(true);
|
||||
play_scene_button->set_icon(gui_base->get_icon("Reload", "EditorIcons"));
|
||||
|
|
|
@ -30,6 +30,9 @@
|
|||
|
||||
#include "editor_run.h"
|
||||
|
||||
#include "plugins/script_editor_plugin.h"
|
||||
#include "script_editor_debugger.h"
|
||||
|
||||
#include "core/project_settings.h"
|
||||
#include "editor_settings.h"
|
||||
|
||||
|
@ -47,8 +50,6 @@ Error EditorRun::run(const String &p_scene, const String &p_custom_args, const L
|
|||
List<String> args;
|
||||
|
||||
String resource_path = ProjectSettings::get_singleton()->get_resource_path();
|
||||
String remote_host = EditorSettings::get_singleton()->get("network/debug/remote_host");
|
||||
int remote_port = (int)EditorSettings::get_singleton()->get("network/debug/remote_port");
|
||||
|
||||
if (resource_path != "") {
|
||||
args.push_back("--path");
|
||||
|
@ -56,8 +57,15 @@ Error EditorRun::run(const String &p_scene, const String &p_custom_args, const L
|
|||
}
|
||||
|
||||
args.push_back("--remote-debug");
|
||||
args.push_back(remote_host + ":" + String::num(remote_port));
|
||||
|
||||
const String conn_string = ScriptEditor::get_singleton()->get_debugger()->get_connection_string();
|
||||
if (!conn_string.empty()) {
|
||||
args.push_back(ScriptEditor::get_singleton()->get_debugger()->get_connection_string());
|
||||
} else { // Try anyway with default settings
|
||||
const String remote_host = EditorSettings::get_singleton()->get("network/debug/remote_host");
|
||||
const int remote_port = (int)EditorSettings::get_singleton()->get("network/debug/remote_port");
|
||||
args.push_back(remote_host + ":" + String::num(remote_port));
|
||||
}
|
||||
args.push_back("--allow_focus_steal_pid");
|
||||
args.push_back(itos(OS::get_singleton()->get_process_id()));
|
||||
|
||||
|
|
|
@ -29,8 +29,8 @@
|
|||
/*************************************************************************/
|
||||
|
||||
#include "script_editor_debugger.h"
|
||||
|
||||
#include "core/io/marshalls.h"
|
||||
#include "core/os/os.h"
|
||||
#include "core/project_settings.h"
|
||||
#include "core/ustring.h"
|
||||
#include "core/version.h"
|
||||
|
@ -1610,13 +1610,25 @@ void ScriptEditorDebugger::start() {
|
|||
perf_max.write[i] = 0;
|
||||
}
|
||||
|
||||
int remote_port = (int)EditorSettings::get_singleton()->get("network/debug/remote_port");
|
||||
if (server->listen(remote_port) != OK) {
|
||||
EditorNode::get_log()->add_message(String("Error listening on port ") + itos(remote_port), EditorLog::MSG_TYPE_ERROR);
|
||||
return;
|
||||
const int max_tries = 6;
|
||||
remote_port = (int)EditorSettings::get_singleton()->get("network/debug/remote_port");
|
||||
int current_try = 0;
|
||||
// Find first available port.
|
||||
Error err = server->listen(remote_port);
|
||||
while (err != OK && current_try < max_tries) {
|
||||
EditorNode::get_log()->add_message(String("Remote debugger failed listening on port: ") + itos(remote_port) + String(" Retrying on new port: " + itos(remote_port + 1)), EditorLog::MSG_TYPE_WARNING);
|
||||
current_try++;
|
||||
remote_port++;
|
||||
OS::get_singleton()->delay_usec(1000);
|
||||
err = server->listen(remote_port);
|
||||
}
|
||||
// No suitable port found.
|
||||
if (err != OK) {
|
||||
EditorNode::get_log()->add_message(String("Error listening on port ") + itos(remote_port), EditorLog::MSG_TYPE_ERROR);
|
||||
EditorNode::get_log()->add_message(String("Remote debugger error listening for connections. No free port"), EditorLog::MSG_TYPE_ERROR);
|
||||
}
|
||||
|
||||
EditorNode::get_singleton()->get_scene_tree_dock()->show_tab_buttons();
|
||||
|
||||
auto_switch_remote_scene_tree = (bool)EditorSettings::get_singleton()->get("debugger/auto_switch_to_remote_scene_tree");
|
||||
if (auto_switch_remote_scene_tree) {
|
||||
EditorNode::get_singleton()->get_scene_tree_dock()->show_remote_tree();
|
||||
|
@ -1651,6 +1663,7 @@ void ScriptEditorDebugger::stop() {
|
|||
reason->set_tooltip("");
|
||||
}
|
||||
|
||||
remote_port = 0;
|
||||
pending_in_queue = 0;
|
||||
message.clear();
|
||||
|
||||
|
@ -2194,6 +2207,11 @@ bool ScriptEditorDebugger::get_debug_with_external_editor() const {
|
|||
return enable_external_editor;
|
||||
}
|
||||
|
||||
String ScriptEditorDebugger::get_connection_string() const {
|
||||
String remote_host = EditorSettings::get_singleton()->get("network/debug/remote_host");
|
||||
return remote_port ? remote_host + ":" + itos(remote_port) : "";
|
||||
}
|
||||
|
||||
void ScriptEditorDebugger::set_debug_with_external_editor(bool p_enabled) {
|
||||
|
||||
enable_external_editor = p_enabled;
|
||||
|
@ -2796,6 +2814,7 @@ ScriptEditorDebugger::ScriptEditorDebugger(EditorNode *p_editor) {
|
|||
enable_external_editor = false;
|
||||
last_error_count = 0;
|
||||
last_warning_count = 0;
|
||||
remote_port = 0;
|
||||
|
||||
EditorNode::get_singleton()->get_pause_button()->connect("pressed", this, "_paused");
|
||||
}
|
||||
|
|
|
@ -125,6 +125,7 @@ private:
|
|||
int last_warning_count;
|
||||
|
||||
bool hide_on_stop;
|
||||
int remote_port;
|
||||
bool enable_external_editor;
|
||||
|
||||
bool skip_breakpoints_value = false;
|
||||
|
@ -281,6 +282,7 @@ public:
|
|||
void set_hide_on_stop(bool p_hide);
|
||||
|
||||
bool get_debug_with_external_editor() const;
|
||||
String get_connection_string() const;
|
||||
void set_debug_with_external_editor(bool p_enabled);
|
||||
|
||||
Ref<Script> get_dump_stack_script() const;
|
||||
|
|
Loading…
Reference in a new issue