summaryrefslogtreecommitdiff
path: root/editor/debugger
diff options
context:
space:
mode:
Diffstat (limited to 'editor/debugger')
-rw-r--r--editor/debugger/editor_debugger_inspector.cpp7
-rw-r--r--editor/debugger/editor_debugger_node.cpp15
-rw-r--r--editor/debugger/editor_debugger_tree.cpp4
-rw-r--r--editor/debugger/script_editor_debugger.cpp136
-rw-r--r--editor/debugger/script_editor_debugger.h10
5 files changed, 159 insertions, 13 deletions
diff --git a/editor/debugger/editor_debugger_inspector.cpp b/editor/debugger/editor_debugger_inspector.cpp
index ddcd32c16f..38bdbe2870 100644
--- a/editor/debugger/editor_debugger_inspector.cpp
+++ b/editor/debugger/editor_debugger_inspector.cpp
@@ -262,11 +262,18 @@ void EditorDebuggerInspector::add_stack_variable(const Array &p_array) {
variables->prop_values[type + n] = v;
variables->update();
edit(variables);
+
+ // To prevent constantly resizing when using filtering.
+ int size_x = get_size().x;
+ if (size_x > get_custom_minimum_size().x) {
+ set_custom_minimum_size(Size2(size_x, 0));
+ }
}
void EditorDebuggerInspector::clear_stack_variables() {
variables->clear();
variables->update();
+ set_custom_minimum_size(Size2(0, 0));
}
String EditorDebuggerInspector::get_stack_variable(const String &p_var) {
diff --git a/editor/debugger/editor_debugger_node.cpp b/editor/debugger/editor_debugger_node.cpp
index 5bc2be60a7..79853b6809 100644
--- a/editor/debugger/editor_debugger_node.cpp
+++ b/editor/debugger/editor_debugger_node.cpp
@@ -75,8 +75,8 @@ EditorDebuggerNode::EditorDebuggerNode() {
remote_scene_tree = memnew(EditorDebuggerTree);
remote_scene_tree->connect("object_selected", callable_mp(this, &EditorDebuggerNode::_remote_object_requested));
remote_scene_tree->connect("save_node", callable_mp(this, &EditorDebuggerNode::_save_node_requested));
- EditorNode::get_singleton()->get_scene_tree_dock()->add_remote_tree_editor(remote_scene_tree);
- EditorNode::get_singleton()->get_scene_tree_dock()->connect("remote_tree_selected", callable_mp(this, &EditorDebuggerNode::request_remote_tree));
+ SceneTreeDock::get_singleton()->add_remote_tree_editor(remote_scene_tree);
+ SceneTreeDock::get_singleton()->connect("remote_tree_selected", callable_mp(this, &EditorDebuggerNode::request_remote_tree));
remote_scene_tree_timeout = EDITOR_DEF("debugger/remote_scene_tree_refresh_interval", 1.0);
inspect_edited_object_timeout = EDITOR_DEF("debugger/remote_inspect_refresh_interval", 0.2);
@@ -95,6 +95,7 @@ ScriptEditorDebugger *EditorDebuggerNode::_add_debugger() {
node->connect("stopped", callable_mp(this, &EditorDebuggerNode::_debugger_stopped), varray(id));
node->connect("stack_frame_selected", callable_mp(this, &EditorDebuggerNode::_stack_frame_selected), varray(id));
node->connect("error_selected", callable_mp(this, &EditorDebuggerNode::_error_selected), varray(id));
+ node->connect("breakpoint_selected", callable_mp(this, &EditorDebuggerNode::_error_selected), varray(id));
node->connect("clear_execution", callable_mp(this, &EditorDebuggerNode::_clear_execution));
node->connect("breaked", callable_mp(this, &EditorDebuggerNode::_breaked), varray(id));
node->connect("remote_tree_updated", callable_mp(this, &EditorDebuggerNode::_remote_tree_updated), varray(id));
@@ -331,10 +332,10 @@ void EditorDebuggerNode::_notification(int p_what) {
// Switch to remote tree view if so desired.
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();
+ SceneTreeDock::get_singleton()->show_remote_tree();
}
// Good to go.
- EditorNode::get_singleton()->get_scene_tree_dock()->show_tab_buttons();
+ SceneTreeDock::get_singleton()->show_tab_buttons();
debugger->set_editor_remote_tree(remote_scene_tree);
debugger->start(server->take_connection());
// Send breakpoints.
@@ -360,8 +361,8 @@ void EditorDebuggerNode::_debugger_stopped(int p_id) {
if (!found) {
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();
- EditorNode::get_singleton()->get_scene_tree_dock()->hide_tab_buttons();
+ SceneTreeDock::get_singleton()->hide_remote_tree();
+ SceneTreeDock::get_singleton()->hide_tab_buttons();
EditorNode::get_singleton()->notify_all_debug_sessions_exited();
}
}
@@ -575,7 +576,7 @@ void EditorDebuggerNode::_remote_object_property_updated(ObjectID p_id, const St
if (obj->remote_object_id != p_id) {
return;
}
- EditorNode::get_singleton()->get_inspector()->update_property(p_property);
+ InspectorDock::get_inspector_singleton()->update_property(p_property);
}
}
diff --git a/editor/debugger/editor_debugger_tree.cpp b/editor/debugger/editor_debugger_tree.cpp
index 70d64615ae..41f4db541d 100644
--- a/editor/debugger/editor_debugger_tree.cpp
+++ b/editor/debugger/editor_debugger_tree.cpp
@@ -128,7 +128,7 @@ void EditorDebuggerTree::_scene_tree_rmb_selected(const Vector2 &p_position) {
void EditorDebuggerTree::update_scene_tree(const SceneDebuggerTree *p_tree, int p_debugger) {
updating_scene_tree = true;
const String last_path = get_selected_path();
- const String filter = EditorNode::get_singleton()->get_scene_tree_dock()->get_filter();
+ const String filter = SceneTreeDock::get_singleton()->get_filter();
bool filter_changed = filter != last_filter;
TreeItem *scroll_item = nullptr;
@@ -186,7 +186,7 @@ void EditorDebuggerTree::update_scene_tree(const SceneDebuggerTree *p_tree, int
// Apply filters.
while (parent) {
const bool had_siblings = item->get_prev() || item->get_next();
- if (filter.is_subsequence_ofi(item->get_text(0))) {
+ if (filter.is_subsequence_ofn(item->get_text(0))) {
break; // Filter matches, must survive.
}
parent->remove_child(item);
diff --git a/editor/debugger/script_editor_debugger.cpp b/editor/debugger/script_editor_debugger.cpp
index b72a20ee2f..ee844fff64 100644
--- a/editor/debugger/script_editor_debugger.cpp
+++ b/editor/debugger/script_editor_debugger.cpp
@@ -788,8 +788,10 @@ void ScriptEditorDebugger::_notification(int p_what) {
le_clear->connect("pressed", callable_mp(this, &ScriptEditorDebugger::_live_edit_clear));
error_tree->connect("item_selected", callable_mp(this, &ScriptEditorDebugger::_error_selected));
error_tree->connect("item_activated", callable_mp(this, &ScriptEditorDebugger::_error_activated));
+ breakpoints_tree->connect("item_activated", callable_mp(this, &ScriptEditorDebugger::_breakpoint_tree_clicked));
vmem_refresh->set_icon(get_theme_icon(SNAME("Reload"), SNAME("EditorIcons")));
vmem_export->set_icon(get_theme_icon(SNAME("Save"), SNAME("EditorIcons")));
+ search->set_right_icon(get_theme_icon(SNAME("Search"), SNAME("EditorIcons")));
reason->add_theme_color_override("font_color", get_theme_color(SNAME("error_color"), SNAME("Editor")));
@@ -864,6 +866,7 @@ void ScriptEditorDebugger::_notification(int p_what) {
docontinue->set_icon(get_theme_icon(SNAME("DebugContinue"), SNAME("EditorIcons")));
vmem_refresh->set_icon(get_theme_icon(SNAME("Reload"), SNAME("EditorIcons")));
vmem_export->set_icon(get_theme_icon(SNAME("Save"), SNAME("EditorIcons")));
+ search->set_right_icon(get_theme_icon(SNAME("Search"), SNAME("EditorIcons")));
} break;
}
}
@@ -893,6 +896,13 @@ void ScriptEditorDebugger::_clear_breakpoints() {
emit_signal("clear_breakpoints");
}
+void ScriptEditorDebugger::_breakpoint_tree_clicked() {
+ TreeItem *selected = breakpoints_tree->get_selected();
+ if (selected->has_meta("line")) {
+ emit_signal(SNAME("breakpoint_selected"), selected->get_parent()->get_text(0), int(selected->get_meta("line")));
+ }
+}
+
void ScriptEditorDebugger::start(Ref<RemoteDebuggerPeer> p_peer) {
_clear_errors_list();
stop();
@@ -1111,7 +1121,7 @@ void ScriptEditorDebugger::_property_changed(Object *p_base, const StringName &p
NodePath path = editor->get_edited_scene()->get_path_to(node);
int pathid = _get_node_path_cache(path);
- if (p_value.is_ref()) {
+ if (p_value.is_ref_counted()) {
Ref<Resource> res = p_value;
if (res.is_valid() && !res->get_path().is_empty()) {
Array msg;
@@ -1137,7 +1147,7 @@ void ScriptEditorDebugger::_property_changed(Object *p_base, const StringName &p
String respath = res->get_path();
int pathid = _get_res_path_cache(respath);
- if (p_value.is_ref()) {
+ if (p_value.is_ref_counted()) {
Ref<Resource> res2 = p_value;
if (res2.is_valid() && !res2->get_path().is_empty()) {
Array msg;
@@ -1351,6 +1361,45 @@ void ScriptEditorDebugger::set_breakpoint(const String &p_path, int p_line, bool
msg.push_back(p_line);
msg.push_back(p_enabled);
_put_msg("breakpoint", msg);
+
+ TreeItem *path_item = breakpoints_tree->search_item_text(p_path);
+ if (path_item == nullptr) {
+ if (!p_enabled) {
+ return;
+ }
+ path_item = breakpoints_tree->create_item();
+ path_item->set_text(0, p_path);
+ }
+
+ int idx = 0;
+ TreeItem *breakpoint_item;
+ for (breakpoint_item = path_item->get_first_child(); breakpoint_item; breakpoint_item = breakpoint_item->get_next()) {
+ if ((int)breakpoint_item->get_meta("line") < p_line) {
+ idx++;
+ continue;
+ }
+
+ if ((int)breakpoint_item->get_meta("line") == p_line) {
+ break;
+ }
+ }
+
+ if (breakpoint_item == nullptr) {
+ if (!p_enabled) {
+ return;
+ }
+ breakpoint_item = breakpoints_tree->create_item(path_item, idx);
+ breakpoint_item->set_meta("line", p_line);
+ breakpoint_item->set_text(0, vformat(TTR("Line %d"), p_line));
+ return;
+ }
+
+ if (!p_enabled) {
+ path_item->remove_child(breakpoint_item);
+ if (path_item->get_first_child() == nullptr) {
+ breakpoints_tree->get_root()->remove_child(path_item);
+ }
+ }
}
void ScriptEditorDebugger::reload_scripts() {
@@ -1417,6 +1466,23 @@ void ScriptEditorDebugger::_clear_errors_list() {
clear_button->set_disabled(true);
}
+void ScriptEditorDebugger::_breakpoints_item_rmb_selected(const Vector2 &p_pos) {
+ breakpoints_menu->clear();
+ breakpoints_menu->set_size(Size2(1, 1));
+
+ const TreeItem *selected = breakpoints_tree->get_selected();
+ String file = selected->get_text(0);
+ if (selected->has_meta("line")) {
+ breakpoints_menu->add_icon_item(get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")), TTR("Delete Breakpoint"), ACTION_DELETE_BREAKPOINT);
+ file = selected->get_parent()->get_text(0);
+ }
+ breakpoints_menu->add_icon_item(get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")), TTR("Delete All Breakpoints in: ") + file, ACTION_DELETE_BREAKPOINTS_IN_FILE);
+ breakpoints_menu->add_icon_item(get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")), TTR("Delete All Breakpoints"), ACTION_DELETE_ALL_BREAKPOINTS);
+
+ breakpoints_menu->set_position(breakpoints_tree->get_global_position() + p_pos);
+ breakpoints_menu->popup();
+}
+
// Right click on specific file(s) or folder(s).
void ScriptEditorDebugger::_error_tree_item_rmb_selected(const Vector2 &p_pos) {
item_menu->clear();
@@ -1491,6 +1557,29 @@ void ScriptEditorDebugger::_item_menu_id_pressed(int p_option) {
line_number));
}
} break;
+ case ACTION_DELETE_BREAKPOINT: {
+ const TreeItem *selected = breakpoints_tree->get_selected();
+ _set_breakpoint(selected->get_parent()->get_text(0), selected->get_meta("line"), false);
+ } break;
+ case ACTION_DELETE_BREAKPOINTS_IN_FILE: {
+ TreeItem *file_item = breakpoints_tree->get_selected();
+ if (file_item->has_meta("line")) {
+ file_item = file_item->get_parent();
+ }
+
+ // Store first else we will be removing as we loop.
+ List<int> lines;
+ for (TreeItem *breakpoint_item = file_item->get_first_child(); breakpoint_item; breakpoint_item = breakpoint_item->get_next()) {
+ lines.push_back(breakpoint_item->get_meta("line"));
+ }
+
+ for (const int &line : lines) {
+ _set_breakpoint(file_item->get_text(0), line, false);
+ }
+ } break;
+ case ACTION_DELETE_ALL_BREAKPOINTS: {
+ _clear_breakpoints();
+ } break;
}
}
@@ -1517,6 +1606,7 @@ void ScriptEditorDebugger::_bind_methods() {
ADD_SIGNAL(MethodInfo("stop_requested"));
ADD_SIGNAL(MethodInfo("stack_frame_selected", PropertyInfo(Variant::INT, "frame")));
ADD_SIGNAL(MethodInfo("error_selected", PropertyInfo(Variant::INT, "error")));
+ ADD_SIGNAL(MethodInfo("breakpoint_selected", PropertyInfo("script"), PropertyInfo(Variant::INT, "line")));
ADD_SIGNAL(MethodInfo("set_execution", PropertyInfo("script"), PropertyInfo(Variant::INT, "line")));
ADD_SIGNAL(MethodInfo("clear_execution", PropertyInfo("script")));
ADD_SIGNAL(MethodInfo("breaked", PropertyInfo(Variant::BOOL, "reallydid"), PropertyInfo(Variant::BOOL, "can_debug"), PropertyInfo(Variant::STRING, "reason"), PropertyInfo(Variant::BOOL, "has_stackdump")));
@@ -1644,9 +1734,15 @@ ScriptEditorDebugger::ScriptEditorDebugger(EditorNode *p_editor) {
docontinue->set_shortcut(ED_GET_SHORTCUT("debugger/continue"));
docontinue->connect("pressed", callable_mp(this, &ScriptEditorDebugger::debug_continue));
+ HSplitContainer *parent_sc = memnew(HSplitContainer);
+ vbc->add_child(parent_sc);
+ parent_sc->set_v_size_flags(SIZE_EXPAND_FILL);
+ parent_sc->set_split_offset(500 * EDSCALE);
+
HSplitContainer *sc = memnew(HSplitContainer);
- vbc->add_child(sc);
sc->set_v_size_flags(SIZE_EXPAND_FILL);
+ sc->set_h_size_flags(SIZE_EXPAND_FILL);
+ parent_sc->add_child(sc);
stack_dump = memnew(Tree);
stack_dump->set_allow_reselect(true);
@@ -1658,15 +1754,47 @@ ScriptEditorDebugger::ScriptEditorDebugger(EditorNode *p_editor) {
stack_dump->connect("cell_selected", callable_mp(this, &ScriptEditorDebugger::_stack_dump_frame_selected));
sc->add_child(stack_dump);
+ VBoxContainer *inspector_vbox = memnew(VBoxContainer);
+ inspector_vbox->set_h_size_flags(SIZE_EXPAND_FILL);
+ sc->add_child(inspector_vbox);
+
+ HBoxContainer *tools_hb = memnew(HBoxContainer);
+ inspector_vbox->add_child(tools_hb);
+
+ search = memnew(LineEdit);
+ search->set_h_size_flags(Control::SIZE_EXPAND_FILL);
+ search->set_placeholder(TTR("Filter stack variables"));
+ search->set_clear_button_enabled(true);
+ tools_hb->add_child(search);
+
inspector = memnew(EditorDebuggerInspector);
inspector->set_h_size_flags(SIZE_EXPAND_FILL);
+ inspector->set_v_size_flags(SIZE_EXPAND_FILL);
inspector->set_enable_capitalize_paths(false);
inspector->set_read_only(true);
inspector->connect("object_selected", callable_mp(this, &ScriptEditorDebugger::_remote_object_selected));
inspector->connect("object_edited", callable_mp(this, &ScriptEditorDebugger::_remote_object_edited));
inspector->connect("object_property_updated", callable_mp(this, &ScriptEditorDebugger::_remote_object_property_updated));
- sc->add_child(inspector);
+ inspector->register_text_enter(search);
+ inspector->set_use_filter(true);
+ inspector_vbox->add_child(inspector);
+
+ breakpoints_tree = memnew(Tree);
+ breakpoints_tree->set_h_size_flags(SIZE_EXPAND_FILL);
+ breakpoints_tree->set_column_titles_visible(true);
+ breakpoints_tree->set_column_title(0, TTR("Breakpoints"));
+ breakpoints_tree->set_allow_reselect(true);
+ breakpoints_tree->set_allow_rmb_select(true);
+ breakpoints_tree->set_hide_root(true);
+ breakpoints_tree->connect("item_rmb_selected", callable_mp(this, &ScriptEditorDebugger::_breakpoints_item_rmb_selected));
+ breakpoints_tree->create_item();
+
+ parent_sc->add_child(breakpoints_tree);
tabs->add_child(dbg);
+
+ breakpoints_menu = memnew(PopupMenu);
+ breakpoints_menu->connect("id_pressed", callable_mp(this, &ScriptEditorDebugger::_item_menu_id_pressed));
+ breakpoints_tree->add_child(breakpoints_menu);
}
{ //errors
diff --git a/editor/debugger/script_editor_debugger.h b/editor/debugger/script_editor_debugger.h
index ff1a852f26..c061e7c61e 100644
--- a/editor/debugger/script_editor_debugger.h
+++ b/editor/debugger/script_editor_debugger.h
@@ -81,6 +81,9 @@ private:
enum Actions {
ACTION_COPY_ERROR,
ACTION_OPEN_SOURCE,
+ ACTION_DELETE_BREAKPOINT,
+ ACTION_DELETE_BREAKPOINTS_IN_FILE,
+ ACTION_DELETE_ALL_BREAKPOINTS,
};
AcceptDialog *msgdialog;
@@ -99,6 +102,9 @@ private:
Button *clear_button;
PopupMenu *item_menu;
+ Tree *breakpoints_tree;
+ PopupMenu *breakpoints_menu;
+
EditorFileDialog *file_dialog;
enum FileDialogPurpose {
SAVE_MONITORS_CSV,
@@ -134,6 +140,7 @@ private:
LineEdit *vmem_total;
Tree *stack_dump;
+ LineEdit *search = nullptr;
EditorDebuggerInspector *inspector;
SceneDebuggerTree *scene_tree;
@@ -197,6 +204,7 @@ private:
void _clear_errors_list();
+ void _breakpoints_item_rmb_selected(const Vector2 &p_pos);
void _error_tree_item_rmb_selected(const Vector2 &p_pos);
void _item_menu_id_pressed(int p_option);
void _tab_changed(int p_tab);
@@ -210,6 +218,8 @@ private:
void _set_breakpoint(const String &p_path, const int &p_line, const bool &p_enabled);
void _clear_breakpoints();
+ void _breakpoint_tree_clicked();
+
protected:
void _notification(int p_what);
static void _bind_methods();