Move the remote scene tree to the scene tree dock.

Ignore all script constants in the global section of the breakpoint stack.
Check property size before send to avoid too large of data be sent.
Fix crash while clear the remote objects from the debugger.
This commit is contained in:
Geequlim 2017-11-16 17:18:36 +08:00
parent c655fc7cd8
commit fab66af7e9
5 changed files with 47 additions and 24 deletions

View file

@ -609,6 +609,16 @@ void ScriptDebuggerRemote::_send_object_id(ObjectID p_id) {
Array prop;
prop.push_back(pi.name);
prop.push_back(pi.type);
//only send information that can be sent..
int len = 0; //test how big is this to encode
encode_variant(var, NULL, len);
if (len > packet_peer_stream->get_output_buffer_max_size()) { //limit to max size
prop.push_back(PROPERTY_HINT_OBJECT_TOO_BIG);
prop.push_back("");
prop.push_back(pi.usage);
prop.push_back(Variant());
} else {
prop.push_back(pi.hint);
if (res.is_null())
prop.push_back(pi.hint_string);
@ -616,6 +626,7 @@ void ScriptDebuggerRemote::_send_object_id(ObjectID p_id) {
prop.push_back(String("RES:") + res->get_path());
prop.push_back(pi.usage);
prop.push_back(var);
}
send_props.push_back(prop);
}

View file

@ -1923,6 +1923,8 @@ void SceneTreeDock::_local_tree_selected() {
remote_tree->hide();
edit_remote->set_pressed(false);
edit_local->set_pressed(true);
_node_selected();
}
void SceneTreeDock::_bind_methods() {

View file

@ -1150,6 +1150,8 @@ void ScriptEditorDebugger::start() {
EditorNode::get_log()->add_message(String("Error listening on port ") + itos(remote_port), true);
return;
}
EditorNode::get_singleton()->get_scene_tree_dock()->show_remote_tree();
set_process(true);
}
@ -1186,6 +1188,7 @@ void ScriptEditorDebugger::stop() {
EditorNode::get_singleton()->get_pause_button()->set_pressed(false);
EditorNode::get_singleton()->get_pause_button()->set_disabled(true);
EditorNode::get_singleton()->get_scene_tree_dock()->hide_remote_tree();
if (hide_on_stop) {
if (is_visible_in_tree())
@ -1662,6 +1665,9 @@ void ScriptEditorDebugger::_set_remote_object(ObjectID p_id, ScriptEditorDebugge
void ScriptEditorDebugger::_clear_remote_objects() {
for (Map<ObjectID, ScriptEditorDebuggerInspectedObject *>::Element *E = remote_objects.front(); E; E = E->next()) {
if (editor->get_editor_history()->get_current() == E->value()->get_instance_id()) {
editor->push_item(NULL);
}
memdelete(E->value());
}
remote_objects.clear();
@ -1825,18 +1831,11 @@ ScriptEditorDebugger::ScriptEditorDebugger(EditorNode *p_editor) {
tabs->add_child(error_split);
}
{ // inquire
inspect_info = memnew(HSplitContainer);
inspect_info->set_name(TTR("Remote Inspector"));
tabs->add_child(inspect_info);
VBoxContainer *info_left = memnew(VBoxContainer);
info_left->set_h_size_flags(SIZE_EXPAND_FILL);
inspect_info->add_child(info_left);
{ // remote scene tree
inspect_scene_tree = memnew(Tree);
info_left->add_margin_child(TTR("Live Scene Tree:"), inspect_scene_tree, true);
EditorNode::get_singleton()->get_scene_tree_dock()->add_remote_tree_editor(inspect_scene_tree);
inspect_scene_tree->set_v_size_flags(SIZE_EXPAND_FILL);
inspect_scene_tree->connect("cell_selected", this, "_scene_tree_selected");
inspect_scene_tree->connect("item_collapsed", this, "_scene_tree_folded");

View file

@ -72,9 +72,6 @@ class ScriptEditorDebugger : public Control {
Button *le_set;
Button *le_clear;
Tree *inspect_scene_tree;
HSplitContainer *inspect_info;
bool updating_scene_tree;
float inspect_scene_tree_timeout;
float inspect_edited_object_timeout;
@ -86,6 +83,7 @@ class ScriptEditorDebugger : public Control {
HSplitContainer *error_split;
ItemList *error_list;
ItemList *error_stack;
Tree *inspect_scene_tree;
int error_count;
int last_error_count;

View file

@ -33,7 +33,7 @@
#include "gdscript_compiler.h"
#include "global_constants.h"
#include "os/file_access.h"
#include "project_settings.h"
#include "core/engine.h"
#ifdef TOOLS_ENABLED
#include "editor/editor_file_system.h"
@ -287,7 +287,7 @@ ScriptInstance *GDScriptLanguage::debug_get_stack_level_instance(int p_level) {
ERR_FAIL_INDEX_V(p_level, _debug_call_stack_pos, NULL);
int l = _debug_call_stack_pos - p_level - 1;
GDInstance *instance = _call_stack[l].instance;
ScriptInstance *instance = _call_stack[l].instance;
return instance;
}
@ -297,14 +297,27 @@ void GDScriptLanguage::debug_get_globals(List<String> *p_globals, List<Variant>
const Map<StringName, int> &name_idx = GDScriptLanguage::get_singleton()->get_global_map();
const Variant *globals = GDScriptLanguage::get_singleton()->get_global_array();
List<Pair<String, Variant> > cinfo;
get_public_constants(&cinfo);
for (const Map<StringName, int>::Element *E = name_idx.front(); E; E = E->next()) {
if (ClassDB::class_exists(E->key()) || ProjectSettings::get_singleton()->has_singleton(E->key()) || E->key() == "PI" || E->key() == "INF" || E->key() == "NAN")
if (ClassDB::class_exists(E->key()) || Engine::get_singleton()->has_singleton(E->key()))
continue;
bool is_script_constant = false;
for (List<Pair<String, Variant> >::Element *CE = cinfo.front(); CE; CE = CE->next()) {
if (CE->get().first == E->key()) {
is_script_constant = true;
break;
}
}
if (is_script_constant)
continue;
const Variant &var = globals[E->value()];
if (Object *obj = var) {
if (Object::cast_to<GDNativeClass>(obj))
if (Object::cast_to<GDScriptNativeClass>(obj))
continue;
}