diff options
Diffstat (limited to 'editor/debugger')
21 files changed, 393 insertions, 357 deletions
diff --git a/editor/debugger/debug_adapter/debug_adapter_parser.cpp b/editor/debugger/debug_adapter/debug_adapter_parser.cpp index e7baeeeded..0caeb90108 100644 --- a/editor/debugger/debug_adapter/debug_adapter_parser.cpp +++ b/editor/debugger/debug_adapter/debug_adapter_parser.cpp @@ -381,12 +381,12 @@ Dictionary DebugAdapterParser::req_scopes(const Dictionary &p_params) const { DAP::StackFrame frame; frame.id = frame_id; - Map<DAP::StackFrame, List<int>>::Element *E = DebugAdapterProtocol::get_singleton()->stackframe_list.find(frame); + HashMap<DAP::StackFrame, List<int>, DAP::StackFrame>::Iterator E = DebugAdapterProtocol::get_singleton()->stackframe_list.find(frame); if (E) { - ERR_FAIL_COND_V(E->value().size() != 3, prepare_error_response(p_params, DAP::ErrorType::UNKNOWN)); + ERR_FAIL_COND_V(E->value.size() != 3, prepare_error_response(p_params, DAP::ErrorType::UNKNOWN)); for (int i = 0; i < 3; i++) { DAP::Scope scope; - scope.variablesReference = E->value()[i]; + scope.variablesReference = E->value[i]; switch (i) { case 0: scope.name = "Locals"; @@ -424,16 +424,16 @@ Dictionary DebugAdapterParser::req_variables(const Dictionary &p_params) const { Dictionary args = p_params["arguments"]; int variable_id = args["variablesReference"]; - Map<int, Array>::Element *E = DebugAdapterProtocol::get_singleton()->variable_list.find(variable_id); + HashMap<int, Array>::Iterator E = DebugAdapterProtocol::get_singleton()->variable_list.find(variable_id); if (E) { if (!DebugAdapterProtocol::get_singleton()->get_current_peer()->supportsVariableType) { - for (int i = 0; i < E->value().size(); i++) { - Dictionary variable = E->value()[i]; + for (int i = 0; i < E->value.size(); i++) { + Dictionary variable = E->value[i]; variable.erase("type"); } } - body["variables"] = E ? E->value() : Array(); + body["variables"] = E ? E->value : Array(); return response; } else { return Dictionary(); diff --git a/editor/debugger/debug_adapter/debug_adapter_protocol.cpp b/editor/debugger/debug_adapter/debug_adapter_protocol.cpp index babe8af8bc..92ea0f15e9 100644 --- a/editor/debugger/debug_adapter/debug_adapter_protocol.cpp +++ b/editor/debugger/debug_adapter/debug_adapter_protocol.cpp @@ -268,12 +268,12 @@ int DebugAdapterProtocol::parse_variant(const Variant &p_var) { x.type = type_vec2; y.type = type_vec2; origin.type = type_vec2; - x.value = transform.elements[0]; - y.value = transform.elements[1]; - origin.value = transform.elements[2]; - x.variablesReference = parse_variant(transform.elements[0]); - y.variablesReference = parse_variant(transform.elements[1]); - origin.variablesReference = parse_variant(transform.elements[2]); + x.value = transform.columns[0]; + y.value = transform.columns[1]; + origin.value = transform.columns[2]; + x.variablesReference = parse_variant(transform.columns[0]); + y.variablesReference = parse_variant(transform.columns[1]); + origin.variablesReference = parse_variant(transform.columns[2]); Array arr; arr.push_back(x.to_json()); @@ -349,20 +349,20 @@ int DebugAdapterProtocol::parse_variant(const Variant &p_var) { case Variant::BASIS: { int id = variable_id++; Basis basis = p_var; - const String type_vec2 = Variant::get_type_name(Variant::VECTOR2); + const String type_vec3 = Variant::get_type_name(Variant::VECTOR3); DAP::Variable x, y, z; x.name = "x"; y.name = "y"; z.name = "z"; - x.type = type_vec2; - y.type = type_vec2; - z.type = type_vec2; - x.value = basis.elements[0]; - y.value = basis.elements[1]; - z.value = basis.elements[2]; - x.variablesReference = parse_variant(basis.elements[0]); - y.variablesReference = parse_variant(basis.elements[1]); - z.variablesReference = parse_variant(basis.elements[2]); + x.type = type_vec3; + y.type = type_vec3; + z.type = type_vec3; + x.value = basis.rows[0]; + y.value = basis.rows[1]; + z.value = basis.rows[2]; + x.variablesReference = parse_variant(basis.rows[0]); + y.variablesReference = parse_variant(basis.rows[1]); + z.variablesReference = parse_variant(basis.rows[2]); Array arr; arr.push_back(x.to_json()); @@ -918,11 +918,11 @@ void DebugAdapterProtocol::on_debug_stack_frame_vars(const int &p_size) { DAP::StackFrame frame; frame.id = _current_frame; ERR_FAIL_COND(!stackframe_list.has(frame)); - List<int> scope_ids = stackframe_list.find(frame)->value(); + List<int> scope_ids = stackframe_list.find(frame)->value; for (List<int>::Element *E = scope_ids.front(); E; E = E->next()) { int variable_id = E->get(); if (variable_list.has(variable_id)) { - variable_list.find(variable_id)->value().clear(); + variable_list.find(variable_id)->value.clear(); } else { variable_list.insert(variable_id, Array()); } @@ -937,7 +937,7 @@ void DebugAdapterProtocol::on_debug_stack_frame_var(const Array &p_data) { DAP::StackFrame frame; frame.id = _current_frame; - List<int> scope_ids = stackframe_list.find(frame)->value(); + List<int> scope_ids = stackframe_list.find(frame)->value; ERR_FAIL_COND(scope_ids.size() != 3); ERR_FAIL_INDEX(stack_var.type, 3); int variable_id = scope_ids[stack_var.type]; @@ -949,7 +949,7 @@ void DebugAdapterProtocol::on_debug_stack_frame_var(const Array &p_data) { variable.type = Variant::get_type_name(stack_var.value.get_type()); variable.variablesReference = parse_variant(stack_var.value); - variable_list.find(variable_id)->value().push_back(variable.to_json()); + variable_list.find(variable_id)->value.push_back(variable.to_json()); _remaining_vars--; } diff --git a/editor/debugger/debug_adapter/debug_adapter_protocol.h b/editor/debugger/debug_adapter/debug_adapter_protocol.h index b54a5f1f3f..a17e550dfc 100644 --- a/editor/debugger/debug_adapter/debug_adapter_protocol.h +++ b/editor/debugger/debug_adapter/debug_adapter_protocol.h @@ -76,7 +76,7 @@ class DebugAdapterProtocol : public Object { private: static DebugAdapterProtocol *singleton; - DebugAdapterParser *parser; + DebugAdapterParser *parser = nullptr; List<Ref<DAPeer>> clients; Ref<TCPServer> server; @@ -111,12 +111,12 @@ private: String _current_request; Ref<DAPeer> _current_peer; - int breakpoint_id; - int stackframe_id; - int variable_id; + int breakpoint_id = 0; + int stackframe_id = 0; + int variable_id = 0; List<DAP::Breakpoint> breakpoint_list; - Map<DAP::StackFrame, List<int>> stackframe_list; - Map<int, Array> variable_list; + HashMap<DAP::StackFrame, List<int>, DAP::StackFrame> stackframe_list; + HashMap<int, Array> variable_list; public: friend class DebugAdapterServer; diff --git a/editor/debugger/debug_adapter/debug_adapter_types.h b/editor/debugger/debug_adapter/debug_adapter_types.h index 77b70909b3..4d77b6d51c 100644 --- a/editor/debugger/debug_adapter/debug_adapter_types.h +++ b/editor/debugger/debug_adapter/debug_adapter_types.h @@ -219,8 +219,11 @@ struct StackFrame { int line; int column; - bool operator<(const StackFrame &p_other) const { - return id < p_other.id; + static uint32_t hash(const StackFrame &p_frame) { + return hash_djb2_one_32(p_frame.id); + } + bool operator==(const StackFrame &p_other) const { + return id == p_other.id; } _FORCE_INLINE_ void from_json(const Dictionary &p_params) { diff --git a/editor/debugger/editor_debugger_inspector.cpp b/editor/debugger/editor_debugger_inspector.cpp index c111190ca3..0e3d424a4b 100644 --- a/editor/debugger/editor_debugger_inspector.cpp +++ b/editor/debugger/editor_debugger_inspector.cpp @@ -68,7 +68,7 @@ void EditorDebuggerRemoteObject::_get_property_list(List<PropertyInfo> *p_list) String EditorDebuggerRemoteObject::get_title() { if (remote_object_id.is_valid()) { - return TTR("Remote ") + String(type_name) + ": " + itos(remote_object_id); + return vformat(TTR("Remote %s:"), String(type_name)) + " " + itos(remote_object_id); } else { return "<null>"; } @@ -146,7 +146,7 @@ ObjectID EditorDebuggerInspector::add_object(const Array &p_arr) { debugObj->prop_list.clear(); int new_props_added = 0; - Set<String> changed; + HashSet<String> changed; for (int i = 0; i < obj.properties.size(); i++) { PropertyInfo &pinfo = obj.properties[i].first; Variant &var = obj.properties[i].second; @@ -157,7 +157,7 @@ ObjectID EditorDebuggerInspector::add_object(const Array &p_arr) { if (path.contains("::")) { // built-in resource String base_path = path.get_slice("::", 0); - RES dependency = ResourceLoader::load(base_path); + Ref<Resource> dependency = ResourceLoader::load(base_path); if (dependency.is_valid()) { remote_dependencies.insert(dependency); } @@ -166,7 +166,7 @@ ObjectID EditorDebuggerInspector::add_object(const Array &p_arr) { if (pinfo.hint_string == "Script") { if (debugObj->get_script() != var) { - debugObj->set_script(REF()); + debugObj->set_script(Ref<RefCounted>()); Ref<Script> script(var); if (!script.is_null()) { ScriptInstance *script_instance = script->placeholder_instance_create(debugObj); @@ -193,8 +193,8 @@ ObjectID EditorDebuggerInspector::add_object(const Array &p_arr) { if (old_prop_size == debugObj->prop_list.size() && new_props_added == 0) { //only some may have changed, if so, then update those, if exist - for (Set<String>::Element *E = changed.front(); E; E = E->next()) { - emit_signal(SNAME("object_property_updated"), debugObj->remote_object_id, E->get()); + for (const String &E : changed) { + emit_signal(SNAME("object_property_updated"), debugObj->remote_object_id, E); } } else { //full update, because props were added or removed @@ -206,7 +206,7 @@ ObjectID EditorDebuggerInspector::add_object(const Array &p_arr) { void EditorDebuggerInspector::clear_cache() { for (const KeyValue<ObjectID, EditorDebuggerRemoteObject *> &E : remote_objects) { EditorNode *editor = EditorNode::get_singleton(); - if (editor->get_editor_history()->get_current() == E.value->get_instance_id()) { + if (editor->get_editor_selection_history()->get_current() == E.value->get_instance_id()) { editor->push_item(nullptr); } memdelete(E.value); @@ -276,8 +276,8 @@ void EditorDebuggerInspector::clear_stack_variables() { } String EditorDebuggerInspector::get_stack_variable(const String &p_var) { - for (Map<StringName, Variant>::Element *E = variables->prop_values.front(); E; E = E->next()) { - String v = E->key().operator String(); + for (KeyValue<StringName, Variant> &E : variables->prop_values) { + String v = E.key.operator String(); if (v.get_slice("/", 1) == p_var) { return variables->get_variant(v); } diff --git a/editor/debugger/editor_debugger_inspector.h b/editor/debugger/editor_debugger_inspector.h index 5cdc4417d0..0e73928558 100644 --- a/editor/debugger/editor_debugger_inspector.h +++ b/editor/debugger/editor_debugger_inspector.h @@ -46,7 +46,7 @@ public: ObjectID remote_object_id; String type_name; List<PropertyInfo> prop_list; - Map<StringName, Variant> prop_values; + HashMap<StringName, Variant> prop_values; ObjectID get_remote_object_id() { return remote_object_id; }; String get_title(); @@ -68,9 +68,9 @@ class EditorDebuggerInspector : public EditorInspector { private: ObjectID inspected_object_id; - Map<ObjectID, EditorDebuggerRemoteObject *> remote_objects; - Set<RES> remote_dependencies; - EditorDebuggerRemoteObject *variables; + HashMap<ObjectID, EditorDebuggerRemoteObject *> remote_objects; + HashSet<Ref<Resource>> remote_dependencies; + EditorDebuggerRemoteObject *variables = nullptr; void _object_selected(ObjectID p_object); void _object_edited(ObjectID p_id, const String &p_prop, const Variant &p_value); diff --git a/editor/debugger/editor_debugger_node.cpp b/editor/debugger/editor_debugger_node.cpp index 7c9a984b6a..e13af59d69 100644 --- a/editor/debugger/editor_debugger_node.cpp +++ b/editor/debugger/editor_debugger_node.cpp @@ -39,6 +39,7 @@ #include "editor/scene_tree_dock.h" #include "scene/gui/menu_button.h" #include "scene/gui/tab_container.h" +#include "scene/resources/packed_scene.h" template <typename Func> void _for_all(TabContainer *p_node, const Func &p_func) { @@ -60,7 +61,6 @@ EditorDebuggerNode::EditorDebuggerNode() { add_theme_constant_override("margin_right", -EditorNode::get_singleton()->get_gui_base()->get_theme_stylebox(SNAME("BottomPanelDebuggerOverride"), SNAME("EditorStyles"))->get_margin(SIDE_RIGHT)); tabs = memnew(TabContainer); - tabs->set_tab_alignment(TabContainer::ALIGNMENT_LEFT); tabs->set_tabs_visible(false); tabs->connect("tab_changed", callable_mp(this, &EditorDebuggerNode::_debugger_changed)); add_child(tabs); @@ -103,6 +103,7 @@ ScriptEditorDebugger *EditorDebuggerNode::_add_debugger() { node->connect("remote_object_updated", callable_mp(this, &EditorDebuggerNode::_remote_object_updated), varray(id)); node->connect("remote_object_property_updated", callable_mp(this, &EditorDebuggerNode::_remote_object_property_updated), varray(id)); node->connect("remote_object_requested", callable_mp(this, &EditorDebuggerNode::_remote_object_requested), varray(id)); + node->connect("errors_cleared", callable_mp(this, &EditorDebuggerNode::_update_errors)); if (tabs->get_tab_count() > 0) { get_debugger(0)->clear_style(); @@ -118,8 +119,8 @@ ScriptEditorDebugger *EditorDebuggerNode::_add_debugger() { } if (!debugger_plugins.is_empty()) { - for (Set<Ref<Script>>::Element *i = debugger_plugins.front(); i; i = i->next()) { - node->add_debugger_plugin(i->get()); + for (const Ref<Script> &i : debugger_plugins) { + node->add_debugger_plugin(i); } } @@ -141,11 +142,22 @@ void EditorDebuggerNode::_error_selected(const String &p_file, int p_line, int p } void EditorDebuggerNode::_text_editor_stack_goto(const ScriptEditorDebugger *p_debugger) { - const String file = p_debugger->get_stack_script_file(); + String file = p_debugger->get_stack_script_file(); if (file.is_empty()) { return; } - stack_script = ResourceLoader::load(file); + if (file.is_resource_file()) { + stack_script = ResourceLoader::load(file); + } else { + // If the script is built-in, it can be opened only if the scene is loaded in memory. + int i = file.find("::"); + int j = file.rfind("(", i); + if (j > -1) { // If the script is named, the string is "name (file)", so we need to extract the path. + file = file.substr(j + 1, file.find(")", i) - j - 1); + } + Ref<PackedScene> ps = ResourceLoader::load(file.get_slice("::", 0)); + stack_script = ResourceLoader::load(file); + } const int line = p_debugger->get_stack_script_line() - 1; emit_signal(SNAME("goto_script_line"), stack_script, line); emit_signal(SNAME("set_execution"), stack_script, line); @@ -170,7 +182,7 @@ void EditorDebuggerNode::_bind_methods() { } EditorDebuggerRemoteObject *EditorDebuggerNode::get_inspected_remote_object() { - return Object::cast_to<EditorDebuggerRemoteObject>(ObjectDB::get_instance(EditorNode::get_singleton()->get_editor_history()->get_current())); + return Object::cast_to<EditorDebuggerRemoteObject>(ObjectDB::get_instance(EditorNode::get_singleton()->get_editor_selection_history()->get_current())); } ScriptEditorDebugger *EditorDebuggerNode::get_debugger(int p_id) const { @@ -256,40 +268,7 @@ void EditorDebuggerNode::_notification(int p_what) { } server->poll(); - // Errors and warnings - int error_count = 0; - int warning_count = 0; - _for_all(tabs, [&](ScriptEditorDebugger *dbg) { - error_count += dbg->get_error_count(); - warning_count += dbg->get_warning_count(); - }); - - if (error_count != last_error_count || warning_count != last_warning_count) { - _for_all(tabs, [&](ScriptEditorDebugger *dbg) { - dbg->update_tabs(); - }); - - if (error_count == 0 && warning_count == 0) { - debugger_button->set_text(TTR("Debugger")); - debugger_button->remove_theme_color_override("font_color"); - debugger_button->set_icon(Ref<Texture2D>()); - } else { - debugger_button->set_text(TTR("Debugger") + " (" + itos(error_count + warning_count) + ")"); - if (error_count >= 1 && warning_count >= 1) { - debugger_button->set_icon(get_theme_icon(SNAME("ErrorWarning"), SNAME("EditorIcons"))); - // Use error color to represent the highest level of severity reported. - debugger_button->add_theme_color_override("font_color", get_theme_color(SNAME("error_color"), SNAME("Editor"))); - } else if (error_count >= 1) { - debugger_button->set_icon(get_theme_icon(SNAME("Error"), SNAME("EditorIcons"))); - debugger_button->add_theme_color_override("font_color", get_theme_color(SNAME("error_color"), SNAME("Editor"))); - } else { - debugger_button->set_icon(get_theme_icon(SNAME("Warning"), SNAME("EditorIcons"))); - debugger_button->add_theme_color_override("font_color", get_theme_color(SNAME("warning_color"), SNAME("Editor"))); - } - } - last_error_count = error_count; - last_warning_count = warning_count; - } + _update_errors(); // Remote scene tree update remote_scene_tree_timeout -= get_process_delta_time(); @@ -350,6 +329,42 @@ void EditorDebuggerNode::_notification(int p_what) { } } +void EditorDebuggerNode::_update_errors() { + int error_count = 0; + int warning_count = 0; + _for_all(tabs, [&](ScriptEditorDebugger *dbg) { + error_count += dbg->get_error_count(); + warning_count += dbg->get_warning_count(); + }); + + if (error_count != last_error_count || warning_count != last_warning_count) { + _for_all(tabs, [&](ScriptEditorDebugger *dbg) { + dbg->update_tabs(); + }); + + if (error_count == 0 && warning_count == 0) { + debugger_button->set_text(TTR("Debugger")); + debugger_button->remove_theme_color_override("font_color"); + debugger_button->set_icon(Ref<Texture2D>()); + } else { + debugger_button->set_text(TTR("Debugger") + " (" + itos(error_count + warning_count) + ")"); + if (error_count >= 1 && warning_count >= 1) { + debugger_button->set_icon(get_theme_icon(SNAME("ErrorWarning"), SNAME("EditorIcons"))); + // Use error color to represent the highest level of severity reported. + debugger_button->add_theme_color_override("font_color", get_theme_color(SNAME("error_color"), SNAME("Editor"))); + } else if (error_count >= 1) { + debugger_button->set_icon(get_theme_icon(SNAME("Error"), SNAME("EditorIcons"))); + debugger_button->add_theme_color_override("font_color", get_theme_color(SNAME("error_color"), SNAME("Editor"))); + } else { + debugger_button->set_icon(get_theme_icon(SNAME("Warning"), SNAME("EditorIcons"))); + debugger_button->add_theme_color_override("font_color", get_theme_color(SNAME("warning_color"), SNAME("Editor"))); + } + } + last_error_count = error_count; + last_warning_count = warning_count; + } +} + void EditorDebuggerNode::_debugger_stopped(int p_id) { ScriptEditorDebugger *dbg = get_debugger(p_id); ERR_FAIL_COND(!dbg); @@ -598,12 +613,12 @@ void EditorDebuggerNode::_save_node_requested(ObjectID p_id, const String &p_fil } // Remote inspector/edit. -void EditorDebuggerNode::_method_changeds(void *p_ud, Object *p_base, const StringName &p_name, VARIANT_ARG_DECLARE) { +void EditorDebuggerNode::_method_changeds(void *p_ud, Object *p_base, const StringName &p_name, const Variant **p_args, int p_argcount) { if (!singleton) { return; } _for_all(singleton->tabs, [&](ScriptEditorDebugger *dbg) { - dbg->_method_changed(p_base, p_name, VARIANT_ARG_PASS); + dbg->_method_changed(p_base, p_name, p_args, p_argcount); }); } diff --git a/editor/debugger/editor_debugger_node.h b/editor/debugger/editor_debugger_node.h index 6fcdbf5f73..8dc53690eb 100644 --- a/editor/debugger/editor_debugger_node.h +++ b/editor/debugger/editor_debugger_node.h @@ -70,6 +70,14 @@ private: String source; int line = 0; + static uint32_t hash(const Breakpoint &p_val) { + uint32_t h = HashMapHasherDefault::hash(p_val.source); + return hash_djb2_one_32(p_val.line, h); + } + bool operator==(const Breakpoint &p_b) const { + return (line == p_b.line && source == p_b.source); + } + bool operator<(const Breakpoint &p_b) const { if (line == p_b.line) { return source < p_b.source; @@ -102,12 +110,13 @@ private: bool debug_with_external_editor = false; bool hide_on_stop = true; CameraOverride camera_override = OVERRIDE_NONE; - Map<Breakpoint, bool> breakpoints; + HashMap<Breakpoint, bool, Breakpoint> breakpoints; - Set<Ref<Script>> debugger_plugins; + HashSet<Ref<Script>> debugger_plugins; ScriptEditorDebugger *_add_debugger(); EditorDebuggerRemoteObject *get_inspected_remote_object(); + void _update_errors(); friend class DebuggerEditorPlugin; friend class DebugAdapterParser; @@ -124,7 +133,7 @@ protected: void _remote_object_requested(ObjectID p_id, int p_debugger); void _save_node_requested(ObjectID p_id, const String &p_file, int p_debugger); - void _clear_execution(REF p_script) { + void _clear_execution(Ref<RefCounted> p_script) { emit_signal(SNAME("clear_execution"), p_script); } @@ -171,7 +180,7 @@ public: // Remote inspector/edit. void request_remote_tree(); - static void _method_changeds(void *p_ud, Object *p_base, const StringName &p_name, VARIANT_ARG_DECLARE); + static void _method_changeds(void *p_ud, Object *p_base, const StringName &p_name, const Variant **p_args, int p_argcount); static void _property_changeds(void *p_ud, Object *p_base, const StringName &p_property, const Variant &p_value); // LiveDebug diff --git a/editor/debugger/editor_debugger_server.cpp b/editor/debugger/editor_debugger_server.cpp index bce131a5fe..63390825c6 100644 --- a/editor/debugger/editor_debugger_server.cpp +++ b/editor/debugger/editor_debugger_server.cpp @@ -122,7 +122,7 @@ Ref<RemoteDebuggerPeer> EditorDebuggerServerTCP::take_connection() { } /// EditorDebuggerServer -Map<StringName, EditorDebuggerServer::CreateServerFunc> EditorDebuggerServer::protocols; +HashMap<StringName, EditorDebuggerServer::CreateServerFunc> EditorDebuggerServer::protocols; EditorDebuggerServer *EditorDebuggerServer::create(const String &p_protocol) { ERR_FAIL_COND_V(!protocols.has(p_protocol), nullptr); diff --git a/editor/debugger/editor_debugger_server.h b/editor/debugger/editor_debugger_server.h index bda4a1ce7d..adf9a27c71 100644 --- a/editor/debugger/editor_debugger_server.h +++ b/editor/debugger/editor_debugger_server.h @@ -39,7 +39,7 @@ public: typedef EditorDebuggerServer *(*CreateServerFunc)(const String &p_uri); private: - static Map<StringName, CreateServerFunc> protocols; + static HashMap<StringName, CreateServerFunc> protocols; public: static void initialize(); diff --git a/editor/debugger/editor_debugger_tree.cpp b/editor/debugger/editor_debugger_tree.cpp index 3a65d015d5..023204b74a 100644 --- a/editor/debugger/editor_debugger_tree.cpp +++ b/editor/debugger/editor_debugger_tree.cpp @@ -57,7 +57,7 @@ void EditorDebuggerTree::_notification(int p_what) { case NOTIFICATION_POSTINITIALIZE: { connect("cell_selected", callable_mp(this, &EditorDebuggerTree::_scene_tree_selected)); connect("item_collapsed", callable_mp(this, &EditorDebuggerTree::_scene_tree_folded)); - connect("item_rmb_selected", callable_mp(this, &EditorDebuggerTree::_scene_tree_rmb_selected)); + connect("item_mouse_selected", callable_mp(this, &EditorDebuggerTree::_scene_tree_rmb_selected)); } break; } } @@ -100,7 +100,11 @@ void EditorDebuggerTree::_scene_tree_folded(Object *p_obj) { } } -void EditorDebuggerTree::_scene_tree_rmb_selected(const Vector2 &p_position) { +void EditorDebuggerTree::_scene_tree_rmb_selected(const Vector2 &p_position, MouseButton p_button) { + if (p_button != MouseButton::RIGHT) { + return; + } + TreeItem *item = get_item_at_position(p_position); if (!item) { return; diff --git a/editor/debugger/editor_debugger_tree.h b/editor/debugger/editor_debugger_tree.h index 58af52b01f..bba524039e 100644 --- a/editor/debugger/editor_debugger_tree.h +++ b/editor/debugger/editor_debugger_tree.h @@ -48,7 +48,7 @@ private: ObjectID inspected_object_id; int debugger_id = 0; bool updating_scene_tree = false; - Set<ObjectID> unfold_cache; + HashSet<ObjectID> unfold_cache; PopupMenu *item_menu = nullptr; EditorFileDialog *file_dialog = nullptr; String last_filter; @@ -56,7 +56,7 @@ private: String _get_path(TreeItem *p_item); void _scene_tree_folded(Object *p_obj); void _scene_tree_selected(); - void _scene_tree_rmb_selected(const Vector2 &p_position); + void _scene_tree_rmb_selected(const Vector2 &p_position, MouseButton p_button); void _item_menu_id_pressed(int p_option); void _file_selected(const String &p_file); diff --git a/editor/debugger/editor_network_profiler.h b/editor/debugger/editor_network_profiler.h index 3e95eb0de6..d2e70a083d 100644 --- a/editor/debugger/editor_network_profiler.h +++ b/editor/debugger/editor_network_profiler.h @@ -42,15 +42,15 @@ class EditorNetworkProfiler : public VBoxContainer { GDCLASS(EditorNetworkProfiler, VBoxContainer) private: - Button *activate; - Button *clear_button; - Tree *counters_display; - LineEdit *incoming_bandwidth_text; - LineEdit *outgoing_bandwidth_text; + Button *activate = nullptr; + Button *clear_button = nullptr; + Tree *counters_display = nullptr; + LineEdit *incoming_bandwidth_text = nullptr; + LineEdit *outgoing_bandwidth_text = nullptr; - Timer *frame_delay; + Timer *frame_delay = nullptr; - Map<ObjectID, SceneDebugger::RPCNodeInfo> nodes_data; + HashMap<ObjectID, SceneDebugger::RPCNodeInfo> nodes_data; void _update_frame(); diff --git a/editor/debugger/editor_performance_profiler.cpp b/editor/debugger/editor_performance_profiler.cpp index 56d1e7cee9..ed451ed68e 100644 --- a/editor/debugger/editor_performance_profiler.cpp +++ b/editor/debugger/editor_performance_profiler.cpp @@ -30,6 +30,7 @@ #include "editor_performance_profiler.h" +#include "editor/editor_property_name_processor.h" #include "editor/editor_scale.h" #include "editor/editor_settings.h" #include "main/performance.h" @@ -96,9 +97,9 @@ void EditorPerformanceProfiler::_monitor_select() { void EditorPerformanceProfiler::_monitor_draw() { Vector<StringName> active; - for (OrderedHashMap<StringName, Monitor>::Element i = monitors.front(); i; i = i.next()) { - if (i.value().item->is_checked(0)) { - active.push_back(i.key()); + for (const KeyValue<StringName, Monitor> &E : monitors) { + if (E.value.item->is_checked(0)) { + active.push_back(E.key); } } @@ -202,23 +203,23 @@ void EditorPerformanceProfiler::_monitor_draw() { } void EditorPerformanceProfiler::_build_monitor_tree() { - Set<StringName> monitor_checked; - for (OrderedHashMap<StringName, Monitor>::Element i = monitors.front(); i; i = i.next()) { - if (i.value().item && i.value().item->is_checked(0)) { - monitor_checked.insert(i.key()); + HashSet<StringName> monitor_checked; + for (KeyValue<StringName, Monitor> &E : monitors) { + if (E.value.item && E.value.item->is_checked(0)) { + monitor_checked.insert(E.key); } } base_map.clear(); monitor_tree->get_root()->clear_children(); - for (OrderedHashMap<StringName, Monitor>::Element i = monitors.front(); i; i = i.next()) { - TreeItem *base = _get_monitor_base(i.value().base); - TreeItem *item = _create_monitor_item(i.value().name, base); - item->set_checked(0, monitor_checked.has(i.key())); - i.value().item = item; - if (!i.value().history.is_empty()) { - i.value().update_value(i.value().history.front()->get()); + for (KeyValue<StringName, Monitor> &E : monitors) { + TreeItem *base = _get_monitor_base(E.value.base); + TreeItem *item = _create_monitor_item(E.value.name, base); + item->set_checked(0, monitor_checked.has(E.key)); + E.value.item = item; + if (!E.value.history.is_empty()) { + E.value.update_value(E.value.history.front()->get()); } } } @@ -251,9 +252,9 @@ void EditorPerformanceProfiler::_marker_input(const Ref<InputEvent> &p_event) { Ref<InputEventMouseButton> mb = p_event; if (mb.is_valid() && mb->is_pressed() && mb->get_button_index() == MouseButton::LEFT) { Vector<StringName> active; - for (OrderedHashMap<StringName, Monitor>::Element i = monitors.front(); i; i = i.next()) { - if (i.value().item->is_checked(0)) { - active.push_back(i.key()); + for (KeyValue<StringName, Monitor> &E : monitors) { + if (E.value.item->is_checked(0)) { + active.push_back(E.key); } } if (active.size() > 0) { @@ -292,12 +293,16 @@ void EditorPerformanceProfiler::_marker_input(const Ref<InputEvent> &p_event) { } void EditorPerformanceProfiler::reset() { - for (OrderedHashMap<StringName, Monitor>::Element i = monitors.front(); i; i = i.next()) { - if (String(i.key()).begins_with("custom:")) { - monitors.erase(i); + HashMap<StringName, Monitor>::Iterator E = monitors.begin(); + while (E != monitors.end()) { + HashMap<StringName, Monitor>::Iterator N = E; + ++N; + if (String(E->key).begins_with("custom:")) { + monitors.remove(E); } else { - i.value().reset(); + E->value.reset(); } + E = N; } _build_monitor_tree(); @@ -307,43 +312,49 @@ void EditorPerformanceProfiler::reset() { } void EditorPerformanceProfiler::update_monitors(const Vector<StringName> &p_names) { - OrderedHashMap<StringName, int> names; + HashMap<StringName, int> names; for (int i = 0; i < p_names.size(); i++) { names.insert("custom:" + p_names[i], Performance::MONITOR_MAX + i); } - for (OrderedHashMap<StringName, Monitor>::Element i = monitors.front(); i; i = i.next()) { - if (String(i.key()).begins_with("custom:")) { - if (!names.has(i.key())) { - monitors.erase(i); - } else { - i.value().frame_index = names[i.key()]; - names.erase(i.key()); + { + HashMap<StringName, Monitor>::Iterator E = monitors.begin(); + while (E != monitors.end()) { + HashMap<StringName, Monitor>::Iterator N = E; + ++N; + if (String(E->key).begins_with("custom:")) { + if (!names.has(E->key)) { + monitors.remove(E); + } else { + E->value.frame_index = names[E->key]; + names.erase(E->key); + } } + E = N; } } - for (OrderedHashMap<StringName, int>::Element i = names.front(); i; i = i.next()) { - String name = String(i.key()).replace_first("custom:", ""); + for (const KeyValue<StringName, int> &E : names) { + String name = String(E.key).replace_first("custom:", ""); String base = "Custom"; if (name.get_slice_count("/") == 2) { base = name.get_slicec('/', 0); name = name.get_slicec('/', 1); } - monitors.insert(i.key(), Monitor(name, base, i.value(), Performance::MONITOR_TYPE_QUANTITY, nullptr)); + monitors.insert(E.key, Monitor(name, base, E.value, Performance::MONITOR_TYPE_QUANTITY, nullptr)); } _build_monitor_tree(); } void EditorPerformanceProfiler::add_profile_frame(const Vector<float> &p_values) { - for (OrderedHashMap<StringName, Monitor>::Element i = monitors.front(); i; i = i.next()) { + for (KeyValue<StringName, Monitor> &E : monitors) { float data = 0.0f; - if (i.value().frame_index >= 0 && i.value().frame_index < p_values.size()) { - data = p_values[i.value().frame_index]; + if (E.value.frame_index >= 0 && E.value.frame_index < p_values.size()) { + data = p_values[E.value.frame_index]; } - i.value().history.push_front(data); - i.value().update_value(data); + E.value.history.push_front(data); + E.value.update_value(data); } marker_frame++; monitor_draw->update(); @@ -386,8 +397,8 @@ EditorPerformanceProfiler::EditorPerformanceProfiler() { monitor_draw->add_child(info_message); for (int i = 0; i < Performance::MONITOR_MAX; i++) { - String base = Performance::get_singleton()->get_monitor_name(Performance::Monitor(i)).get_slicec('/', 0).capitalize(); - String name = Performance::get_singleton()->get_monitor_name(Performance::Monitor(i)).get_slicec('/', 1).capitalize(); + String base = EditorPropertyNameProcessor::get_singleton()->process_name(Performance::get_singleton()->get_monitor_name(Performance::Monitor(i)).get_slicec('/', 0), EditorPropertyNameProcessor::STYLE_CAPITALIZED); + String name = EditorPropertyNameProcessor::get_singleton()->process_name(Performance::get_singleton()->get_monitor_name(Performance::Monitor(i)).get_slicec('/', 1), EditorPropertyNameProcessor::STYLE_CAPITALIZED); monitors.insert(Performance::get_singleton()->get_monitor_name(Performance::Monitor(i)), Monitor(name, base, i, Performance::get_singleton()->get_monitor_type(Performance::Monitor(i)), nullptr)); } diff --git a/editor/debugger/editor_performance_profiler.h b/editor/debugger/editor_performance_profiler.h index 998ecc5bb6..607de5a134 100644 --- a/editor/debugger/editor_performance_profiler.h +++ b/editor/debugger/editor_performance_profiler.h @@ -31,8 +31,8 @@ #ifndef EDITOR_PERFORMANCE_PROFILER_H #define EDITOR_PERFORMANCE_PROFILER_H -#include "core/templates/map.h" -#include "core/templates/ordered_hash_map.h" +#include "core/templates/hash_map.h" +#include "core/templates/rb_map.h" #include "main/performance.h" #include "scene/gui/control.h" #include "scene/gui/label.h" @@ -59,14 +59,14 @@ private: void reset(); }; - OrderedHashMap<StringName, Monitor> monitors; + HashMap<StringName, Monitor> monitors; - Map<StringName, TreeItem *> base_map; - Tree *monitor_tree; - Control *monitor_draw; - Label *info_message; + HashMap<StringName, TreeItem *> base_map; + Tree *monitor_tree = nullptr; + Control *monitor_draw = nullptr; + Label *info_message = nullptr; StringName marker_key; - int marker_frame; + int marker_frame = 0; const int MARGIN = 4; const int POINT_SEPARATION = 5; const int MARKER_MARGIN = 2; diff --git a/editor/debugger/editor_profiler.cpp b/editor/debugger/editor_profiler.cpp index 4b263e5152..1b1cdbd9ef 100644 --- a/editor/debugger/editor_profiler.cpp +++ b/editor/debugger/editor_profiler.cpp @@ -86,7 +86,7 @@ void EditorProfiler::add_frame_metric(const Metric &p_metric, bool p_final) { void EditorProfiler::clear() { int metric_size = EditorSettings::get_singleton()->get("debugger/profiler_frame_history_size"); - metric_size = CLAMP(metric_size, 60, 1024); + metric_size = CLAMP(metric_size, 60, 10000); frame_metrics.clear(); frame_metrics.resize(metric_size); total_metrics = 0; @@ -198,18 +198,18 @@ void EditorProfiler::_update_plot() { for (int i = 0; i < total_metrics; i++) { const Metric &m = _get_frame_metric(i); - for (Set<StringName>::Element *E = plot_sigs.front(); E; E = E->next()) { - const Map<StringName, Metric::Category *>::Element *F = m.category_ptrs.find(E->get()); + for (const StringName &E : plot_sigs) { + HashMap<StringName, Metric::Category *>::ConstIterator F = m.category_ptrs.find(E); if (F) { - highest = MAX(F->get()->total_time, highest); + highest = MAX(F->value->total_time, highest); } - const Map<StringName, Metric::Category::Item *>::Element *G = m.item_ptrs.find(E->get()); + HashMap<StringName, Metric::Category::Item *>::ConstIterator G = m.item_ptrs.find(E); if (G) { if (use_self) { - highest = MAX(G->get()->self, highest); + highest = MAX(G->value->self, highest); } else { - highest = MAX(G->get()->total, highest); + highest = MAX(G->value->total, highest); } } } @@ -225,7 +225,7 @@ void EditorProfiler::_update_plot() { int *column = columnv.ptrw(); - Map<StringName, int> prev_plots; + HashMap<StringName, int> prev_plots; for (int i = 0; i < total_metrics * w / frame_metrics.size() - 1; i++) { for (int j = 0; j < h * 4; j++) { @@ -234,34 +234,34 @@ void EditorProfiler::_update_plot() { int current = i * frame_metrics.size() / w; - for (Set<StringName>::Element *E = plot_sigs.front(); E; E = E->next()) { + for (const StringName &E : plot_sigs) { const Metric &m = _get_frame_metric(current); float value = 0; - const Map<StringName, Metric::Category *>::Element *F = m.category_ptrs.find(E->get()); + HashMap<StringName, Metric::Category *>::ConstIterator F = m.category_ptrs.find(E); if (F) { - value = F->get()->total_time; + value = F->value->total_time; } - const Map<StringName, Metric::Category::Item *>::Element *G = m.item_ptrs.find(E->get()); + HashMap<StringName, Metric::Category::Item *>::ConstIterator G = m.item_ptrs.find(E); if (G) { if (use_self) { - value = G->get()->self; + value = G->value->self; } else { - value = G->get()->total; + value = G->value->total; } } int plot_pos = CLAMP(int(value * h / highest), 0, h - 1); int prev_plot = plot_pos; - Map<StringName, int>::Element *H = prev_plots.find(E->get()); + HashMap<StringName, int>::Iterator H = prev_plots.find(E); if (H) { - prev_plot = H->get(); - H->get() = plot_pos; + prev_plot = H->value; + H->value = plot_pos; } else { - prev_plots[E->get()] = plot_pos; + prev_plots[E] = plot_pos; } plot_pos = h - plot_pos - 1; @@ -271,7 +271,7 @@ void EditorProfiler::_update_plot() { SWAP(prev_plot, plot_pos); } - Color col = _get_color_from_signature(E->get()); + Color col = _get_color_from_signature(E); for (int j = prev_plot; j <= plot_pos; j++) { column[j * 4 + 0] += Math::fast_ftoi(CLAMP(col.r * 255, 0, 255)); @@ -396,6 +396,7 @@ void EditorProfiler::_notification(int p_what) { switch (p_what) { case NOTIFICATION_ENTER_TREE: case NOTIFICATION_LAYOUT_DIRECTION_CHANGED: + case NOTIFICATION_THEME_CHANGED: case NOTIFICATION_TRANSLATION_CHANGED: { activate->set_icon(get_theme_icon(SNAME("Play"), SNAME("EditorIcons"))); clear_button->set_icon(get_theme_icon(SNAME("Clear"), SNAME("EditorIcons"))); @@ -514,7 +515,7 @@ Vector<Vector<String>> EditorProfiler::get_data_as_csv() const { } // Different metrics may contain different number of categories. - Set<StringName> possible_signatures; + HashSet<StringName> possible_signatures; for (int i = 0; i < frame_metrics.size(); i++) { const Metric &m = frame_metrics[i]; if (!m.valid) { @@ -529,13 +530,13 @@ Vector<Vector<String>> EditorProfiler::get_data_as_csv() const { } // Generate CSV header and cache indices. - Map<StringName, int> sig_map; + HashMap<StringName, int> sig_map; Vector<String> signatures; signatures.resize(possible_signatures.size()); int sig_index = 0; - for (const Set<StringName>::Element *E = possible_signatures.front(); E; E = E->next()) { - signatures.write[sig_index] = E->get(); - sig_map[E->get()] = sig_index; + for (const StringName &E : possible_signatures) { + signatures.write[sig_index] = E; + sig_map[E] = sig_index; sig_index++; } res.push_back(signatures); @@ -659,11 +660,8 @@ EditorProfiler::EditorProfiler() { h_split->add_child(graph); graph->set_h_size_flags(SIZE_EXPAND_FILL); - int metric_size = CLAMP(int(EDITOR_DEF("debugger/profiler_frame_history_size", 600)), 60, 1024); + int metric_size = CLAMP(int(EDITOR_GET("debugger/profiler_frame_history_size")), 60, 10000); frame_metrics.resize(metric_size); - total_metrics = 0; - last_metric = -1; - hover_metric = -1; EDITOR_DEF("debugger/profiler_frame_max_functions", 64); @@ -681,7 +679,4 @@ EditorProfiler::EditorProfiler() { plot_sigs.insert("physics_frame_time"); plot_sigs.insert("category_frame_time"); - - seeking = false; - graph_height = 1; } diff --git a/editor/debugger/editor_profiler.h b/editor/debugger/editor_profiler.h index 45f7ac39c1..cb01a1819f 100644 --- a/editor/debugger/editor_profiler.h +++ b/editor/debugger/editor_profiler.h @@ -49,7 +49,7 @@ public: int frame_number = 0; float frame_time = 0; - float idle_time = 0; + float process_time = 0; float physics_time = 0; float physics_frame_time = 0; @@ -73,8 +73,8 @@ public: Vector<Category> categories; - Map<StringName, Category *> category_ptrs; - Map<StringName, Category::Item *> item_ptrs; + HashMap<StringName, Category *> category_ptrs; + HashMap<StringName, Category::Item *> item_ptrs; }; enum DisplayMode { @@ -90,37 +90,37 @@ public: }; private: - Button *activate; - Button *clear_button; - TextureRect *graph; + Button *activate = nullptr; + Button *clear_button = nullptr; + TextureRect *graph = nullptr; Ref<ImageTexture> graph_texture; Vector<uint8_t> graph_image; - Tree *variables; - HSplitContainer *h_split; + Tree *variables = nullptr; + HSplitContainer *h_split = nullptr; - Set<StringName> plot_sigs; + HashSet<StringName> plot_sigs; - OptionButton *display_mode; - OptionButton *display_time; + OptionButton *display_mode = nullptr; + OptionButton *display_time = nullptr; - SpinBox *cursor_metric_edit; + SpinBox *cursor_metric_edit = nullptr; Vector<Metric> frame_metrics; - int total_metrics; - int last_metric; + int total_metrics = 0; + int last_metric = -1; - int max_functions; + int max_functions = 0; - bool updating_frame; + bool updating_frame = false; - int hover_metric; + int hover_metric = -1; - float graph_height; + float graph_height = 1.0f; - bool seeking; + bool seeking = false; - Timer *frame_delay; - Timer *plot_delay; + Timer *frame_delay = nullptr; + Timer *plot_delay = nullptr; void _update_frame(); diff --git a/editor/debugger/editor_visual_profiler.cpp b/editor/debugger/editor_visual_profiler.cpp index 2a1b0029d4..9def646f3f 100644 --- a/editor/debugger/editor_visual_profiler.cpp +++ b/editor/debugger/editor_visual_profiler.cpp @@ -67,7 +67,7 @@ void EditorVisualProfiler::add_frame_metric(const Metric &p_metric) { updating_frame = true; cursor_metric_edit->set_max(frame_metrics[last_metric].frame_number); - cursor_metric_edit->set_min(MAX(frame_metrics[last_metric].frame_number - frame_metrics.size(), 0)); + cursor_metric_edit->set_min(MAX(frame_metrics[last_metric].frame_number - frame_metrics.size(), 0u)); if (!seeking) { cursor_metric_edit->set_value(frame_metrics[last_metric].frame_number); @@ -93,7 +93,7 @@ void EditorVisualProfiler::add_frame_metric(const Metric &p_metric) { void EditorVisualProfiler::clear() { int metric_size = EditorSettings::get_singleton()->get("debugger/profiler_frame_history_size"); - metric_size = CLAMP(metric_size, 60, 1024); + metric_size = CLAMP(metric_size, 60, 10000); frame_metrics.clear(); frame_metrics.resize(metric_size); last_metric = -1; @@ -143,12 +143,12 @@ void EditorVisualProfiler::_item_selected() { } void EditorVisualProfiler::_update_plot() { - int w = graph->get_size().width; - int h = graph->get_size().height; + const int w = graph->get_size().width; + const int h = graph->get_size().height; bool reset_texture = false; - int desired_len = w * h * 4; + const int desired_len = w * h * 4; if (graph_image.size() != desired_len) { reset_texture = true; @@ -156,12 +156,13 @@ void EditorVisualProfiler::_update_plot() { } uint8_t *wr = graph_image.ptrw(); + const Color background_color = get_theme_color("dark_color_2", "Editor"); - //clear + // Clear the previous frame and set the background color. for (int i = 0; i < desired_len; i += 4) { - wr[i + 0] = 0; - wr[i + 1] = 0; - wr[i + 2] = 0; + wr[i + 0] = Math::fast_ftoi(background_color.r * 255); + wr[i + 1] = Math::fast_ftoi(background_color.g * 255); + wr[i + 2] = Math::fast_ftoi(background_color.b * 255); wr[i + 3] = 255; } @@ -259,9 +260,9 @@ void EditorVisualProfiler::_update_plot() { uint8_t r, g, b; if (column_cpu[j].a == 0) { - r = 0; - g = 0; - b = 0; + r = Math::fast_ftoi(background_color.r * 255); + g = Math::fast_ftoi(background_color.g * 255); + b = Math::fast_ftoi(background_color.b * 255); } else { r = CLAMP((column_cpu[j].r / column_cpu[j].a) * 255.0, 0, 255); g = CLAMP((column_cpu[j].g / column_cpu[j].a) * 255.0, 0, 255); @@ -279,9 +280,9 @@ void EditorVisualProfiler::_update_plot() { uint8_t r, g, b; if (column_gpu[j].a == 0) { - r = 0; - g = 0; - b = 0; + r = Math::fast_ftoi(background_color.r * 255); + g = Math::fast_ftoi(background_color.g * 255); + b = Math::fast_ftoi(background_color.b * 255); } else { r = CLAMP((column_gpu[j].r / column_gpu[j].a) * 255.0, 0, 255); g = CLAMP((column_gpu[j].g / column_gpu[j].a) * 255.0, 0, 255); @@ -425,6 +426,7 @@ void EditorVisualProfiler::_notification(int p_what) { switch (p_what) { case NOTIFICATION_ENTER_TREE: case NOTIFICATION_LAYOUT_DIRECTION_CHANGED: + case NOTIFICATION_THEME_CHANGED: case NOTIFICATION_TRANSLATION_CHANGED: { if (is_layout_rtl()) { activate->set_icon(get_theme_icon(SNAME("PlayBackwards"), SNAME("EditorIcons"))); @@ -440,8 +442,11 @@ void EditorVisualProfiler::_graph_tex_draw() { if (last_metric < 0) { return; } + Ref<Font> font = get_theme_font(SNAME("font"), SNAME("Label")); int font_size = get_theme_font_size(SNAME("font_size"), SNAME("Label")); + const Color color = get_theme_color(SNAME("font_color"), SNAME("Editor")); + if (seeking) { int max_frames = frame_metrics.size(); int frame = cursor_metric_edit->get_value() - (frame_metrics[last_metric].frame_number - max_frames + 1); @@ -451,10 +456,9 @@ void EditorVisualProfiler::_graph_tex_draw() { int half_width = graph->get_size().x / 2; int cur_x = frame * half_width / max_frames; - //cur_x /= 2.0; - graph->draw_line(Vector2(cur_x, 0), Vector2(cur_x, graph->get_size().y), Color(1, 1, 1, 0.8)); - graph->draw_line(Vector2(cur_x + half_width, 0), Vector2(cur_x + half_width, graph->get_size().y), Color(1, 1, 1, 0.8)); + graph->draw_line(Vector2(cur_x, 0), Vector2(cur_x, graph->get_size().y), color * Color(1, 1, 1)); + graph->draw_line(Vector2(cur_x + half_width, 0), Vector2(cur_x + half_width, graph->get_size().y), color * Color(1, 1, 1)); } if (graph_height_cpu > 0) { @@ -462,10 +466,10 @@ void EditorVisualProfiler::_graph_tex_draw() { int half_width = graph->get_size().x / 2; - graph->draw_line(Vector2(0, frame_y), Vector2(half_width, frame_y), Color(1, 1, 1, 0.3)); + graph->draw_line(Vector2(0, frame_y), Vector2(half_width, frame_y), color * Color(1, 1, 1, 0.5)); - String limit_str = String::num(graph_limit, 2); - graph->draw_string(font, Vector2(half_width - font->get_string_size(limit_str, font_size).x - 2, frame_y - 2), limit_str, HORIZONTAL_ALIGNMENT_LEFT, -1, font_size, Color(1, 1, 1, 0.6)); + const String limit_str = String::num(graph_limit, 2) + " ms"; + graph->draw_string(font, Vector2(half_width - font->get_string_size(limit_str, font_size).x - 2, frame_y - 2), limit_str, HORIZONTAL_ALIGNMENT_LEFT, -1, font_size, color * Color(1, 1, 1, 0.75)); } if (graph_height_gpu > 0) { @@ -473,14 +477,14 @@ void EditorVisualProfiler::_graph_tex_draw() { int half_width = graph->get_size().x / 2; - graph->draw_line(Vector2(half_width, frame_y), Vector2(graph->get_size().x, frame_y), Color(1, 1, 1, 0.3)); + graph->draw_line(Vector2(half_width, frame_y), Vector2(graph->get_size().x, frame_y), color * Color(1, 1, 1, 0.5)); - String limit_str = String::num(graph_limit, 2); - graph->draw_string(font, Vector2(half_width * 2 - font->get_string_size(limit_str, font_size).x - 2, frame_y - 2), limit_str, HORIZONTAL_ALIGNMENT_LEFT, -1, font_size, Color(1, 1, 1, 0.6)); + const String limit_str = String::num(graph_limit, 2) + " ms"; + graph->draw_string(font, Vector2(half_width * 2 - font->get_string_size(limit_str, font_size).x - 2, frame_y - 2), limit_str, HORIZONTAL_ALIGNMENT_LEFT, -1, font_size, color * Color(1, 1, 1, 0.75)); } - graph->draw_string(font, Vector2(font->get_string_size("X", font_size).x, font->get_ascent(font_size) + 2), "CPU:", HORIZONTAL_ALIGNMENT_LEFT, -1, font_size, Color(1, 1, 1, 0.8)); - graph->draw_string(font, Vector2(font->get_string_size("X", font_size).x + graph->get_size().width / 2, font->get_ascent(font_size) + 2), "GPU:", HORIZONTAL_ALIGNMENT_LEFT, -1, font_size, Color(1, 1, 1, 0.8)); + graph->draw_string(font, Vector2(font->get_string_size("X", font_size).x, font->get_ascent(font_size) + 2), "CPU:", HORIZONTAL_ALIGNMENT_LEFT, -1, font_size, color * Color(1, 1, 1)); + graph->draw_string(font, Vector2(font->get_string_size("X", font_size).x + graph->get_size().width / 2, font->get_ascent(font_size) + 2), "GPU:", HORIZONTAL_ALIGNMENT_LEFT, -1, font_size, color * Color(1, 1, 1)); } void EditorVisualProfiler::_graph_tex_mouse_exit() { @@ -724,7 +728,7 @@ EditorVisualProfiler::EditorVisualProfiler() { hb->add_child(memnew(Label(TTR("Measure:")))); display_mode = memnew(OptionButton); - display_mode->add_item(TTR("Frame Time (msec)")); + display_mode->add_item(TTR("Frame Time (ms)")); display_mode->add_item(TTR("Frame %")); display_mode->connect("item_selected", callable_mp(this, &EditorVisualProfiler::_combo_changed)); @@ -778,7 +782,6 @@ EditorVisualProfiler::EditorVisualProfiler() { graph = memnew(TextureRect); graph->set_ignore_texture_size(true); graph->set_mouse_filter(MOUSE_FILTER_STOP); - //graph->set_ignore_mouse(false); graph->connect("draw", callable_mp(this, &EditorVisualProfiler::_graph_tex_draw)); graph->connect("gui_input", callable_mp(this, &EditorVisualProfiler::_graph_tex_input)); graph->connect("mouse_exited", callable_mp(this, &EditorVisualProfiler::_graph_tex_mouse_exit)); @@ -786,13 +789,8 @@ EditorVisualProfiler::EditorVisualProfiler() { h_split->add_child(graph); graph->set_h_size_flags(SIZE_EXPAND_FILL); - int metric_size = CLAMP(int(EDITOR_DEF("debugger/profiler_frame_history_size", 600)), 60, 1024); + int metric_size = CLAMP(int(EDITOR_GET("debugger/profiler_frame_history_size")), 60, 10000); frame_metrics.resize(metric_size); - last_metric = -1; - //cursor_metric=-1; - hover_metric = -1; - - //display_mode=DISPLAY_FRAME_TIME; frame_delay = memnew(Timer); frame_delay->set_wait_time(0.1); @@ -805,12 +803,4 @@ EditorVisualProfiler::EditorVisualProfiler() { plot_delay->set_one_shot(true); add_child(plot_delay); plot_delay->connect("timeout", callable_mp(this, &EditorVisualProfiler::_update_plot)); - - seeking = false; - graph_height_cpu = 1; - graph_height_gpu = 1; - - graph_limit = 1000 / 60.0; - - //activate->set_disabled(true); } diff --git a/editor/debugger/editor_visual_profiler.h b/editor/debugger/editor_visual_profiler.h index 55ba725ae8..4e5169da9e 100644 --- a/editor/debugger/editor_visual_profiler.h +++ b/editor/debugger/editor_visual_profiler.h @@ -67,40 +67,39 @@ public: }; private: - Button *activate; - Button *clear_button; + Button *activate = nullptr; + Button *clear_button = nullptr; - TextureRect *graph; + TextureRect *graph = nullptr; Ref<ImageTexture> graph_texture; Vector<uint8_t> graph_image; - Tree *variables; - HSplitContainer *h_split; - CheckBox *frame_relative; - CheckBox *linked; + Tree *variables = nullptr; + HSplitContainer *h_split = nullptr; + CheckBox *frame_relative = nullptr; + CheckBox *linked = nullptr; - OptionButton *display_mode; + OptionButton *display_mode = nullptr; - SpinBox *cursor_metric_edit; + SpinBox *cursor_metric_edit = nullptr; Vector<Metric> frame_metrics; - int last_metric; + int last_metric = -1; - StringName selected_area; + int hover_metric = -1; - bool updating_frame; + StringName selected_area; - //int cursor_metric; - int hover_metric; + bool updating_frame = false; - float graph_height_cpu; - float graph_height_gpu; + float graph_height_cpu = 1.0f; + float graph_height_gpu = 1.0f; - float graph_limit; + float graph_limit = 1000.0f / 60; - bool seeking; + bool seeking = false; - Timer *frame_delay; - Timer *plot_delay; + Timer *frame_delay = nullptr; + Timer *plot_delay = nullptr; void _update_frame(bool p_focus_selected = false); diff --git a/editor/debugger/script_editor_debugger.cpp b/editor/debugger/script_editor_debugger.cpp index 645d7608f3..05409dbeeb 100644 --- a/editor/debugger/script_editor_debugger.cpp +++ b/editor/debugger/script_editor_debugger.cpp @@ -44,6 +44,7 @@ #include "editor/editor_file_dialog.h" #include "editor/editor_log.h" #include "editor/editor_node.h" +#include "editor/editor_property_name_processor.h" #include "editor/editor_scale.h" #include "editor/editor_settings.h" #include "editor/plugins/canvas_item_editor_plugin.h" @@ -135,15 +136,15 @@ void ScriptEditorDebugger::debug_continue() { void ScriptEditorDebugger::update_tabs() { if (error_count == 0 && warning_count == 0) { errors_tab->set_name(TTR("Errors")); - tabs->set_tab_icon(errors_tab->get_index(), Ref<Texture2D>()); + tabs->set_tab_icon(tabs->get_tab_idx_from_control(errors_tab), Ref<Texture2D>()); } else { errors_tab->set_name(TTR("Errors") + " (" + itos(error_count + warning_count) + ")"); if (error_count >= 1 && warning_count >= 1) { - tabs->set_tab_icon(errors_tab->get_index(), get_theme_icon(SNAME("ErrorWarning"), SNAME("EditorIcons"))); + tabs->set_tab_icon(tabs->get_tab_idx_from_control(errors_tab), get_theme_icon(SNAME("ErrorWarning"), SNAME("EditorIcons"))); } else if (error_count >= 1) { - tabs->set_tab_icon(errors_tab->get_index(), get_theme_icon(SNAME("Error"), SNAME("EditorIcons"))); + tabs->set_tab_icon(tabs->get_tab_idx_from_control(errors_tab), get_theme_icon(SNAME("Error"), SNAME("EditorIcons"))); } else { - tabs->set_tab_icon(errors_tab->get_index(), get_theme_icon(SNAME("Warning"), SNAME("EditorIcons"))); + tabs->set_tab_icon(tabs->get_tab_idx_from_control(errors_tab), get_theme_icon(SNAME("Warning"), SNAME("EditorIcons"))); } } } @@ -163,7 +164,7 @@ void ScriptEditorDebugger::_file_selected(const String &p_file) { switch (file_dialog_purpose) { case SAVE_MONITORS_CSV: { Error err; - FileAccessRef file = FileAccess::open(p_file, FileAccess::WRITE, &err); + Ref<FileAccess> file = FileAccess::open(p_file, FileAccess::WRITE, &err); if (err != OK) { ERR_PRINT("Failed to open " + p_file); @@ -208,7 +209,7 @@ void ScriptEditorDebugger::_file_selected(const String &p_file) { } break; case SAVE_VRAM_CSV: { Error err; - FileAccessRef file = FileAccess::open(p_file, FileAccess::WRITE, &err); + Ref<FileAccess> file = FileAccess::open(p_file, FileAccess::WRITE, &err); if (err != OK) { ERR_PRINT("Failed to open " + p_file); @@ -392,7 +393,7 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, const Array &p_da stack_dump_info.push_back(d); s->set_metadata(0, d); - String line = itos(i) + " - " + String(d["file"]) + ":" + itos(d["line"]) + " - at function: " + d["function"]; + String line = itos(i) + " - " + String(d["file"]) + ":" + itos(d["line"]) + " - at function: " + String(d["function"]); s->set_text(0, line); if (i == 0) { @@ -605,7 +606,7 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, const Array &p_da metric.valid = true; metric.frame_number = frame.frame_number; metric.frame_time = frame.frame_time; - metric.idle_time = frame.idle_time; + metric.process_time = frame.process_time; metric.physics_time = frame.physics_time; metric.physics_frame_time = frame.physics_frame_time; @@ -626,10 +627,10 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, const Array &p_da frame_time.items.push_back(item); - item.name = "Idle Time"; - item.total = metric.idle_time; + item.name = "Process Time"; + item.total = metric.process_time; item.self = item.total; - item.signature = "idle_time"; + item.signature = "process_time"; frame_time.items.push_back(item); @@ -647,7 +648,7 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, const Array &p_da const ServersDebugger::ServerInfo &srv = frame.servers[i]; EditorProfiler::Metric::Category c; const String name = srv.name; - c.name = name.capitalize(); + c.name = EditorPropertyNameProcessor::get_singleton()->process_name(name, EditorPropertyNameProcessor::STYLE_CAPITALIZED); c.items.resize(srv.functions.size()); c.total_time = 0; c.signature = "categ::" + name; @@ -659,7 +660,7 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, const Array &p_da item.self = srv.functions[j].time; item.total = item.self; item.signature = "categ::" + name + "::" + item.name; - item.name = item.name.capitalize(); + item.name = EditorPropertyNameProcessor::get_singleton()->process_name(item.name, EditorPropertyNameProcessor::STYLE_CAPITALIZED); c.total_time += item.total; c.items.write[j] = item; } @@ -741,9 +742,9 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, const Array &p_da bool parsed = false; const String cap = p_msg.substr(0, colon_index); - Map<StringName, Callable>::Element *element = captures.find(cap); + HashMap<StringName, Callable>::Iterator element = captures.find(cap); if (element) { - Callable &c = element->value(); + Callable &c = element->value; ERR_FAIL_COND_MSG(c.is_null(), "Invalid callable registered: " + cap); Variant cmd = p_msg.substr(colon_index + 1), data = p_data; const Variant *args[2] = { &cmd, &data }; @@ -779,18 +780,20 @@ void ScriptEditorDebugger::_set_reason_text(const String &p_reason, MessageType void ScriptEditorDebugger::_notification(int p_what) { switch (p_what) { case NOTIFICATION_ENTER_TREE: { - skip_breakpoints->set_icon(get_theme_icon(SNAME("DebugSkipBreakpointsOff"), SNAME("EditorIcons"))); - copy->set_icon(get_theme_icon(SNAME("ActionCopy"), SNAME("EditorIcons"))); - - step->set_icon(get_theme_icon(SNAME("DebugStep"), SNAME("EditorIcons"))); - next->set_icon(get_theme_icon(SNAME("DebugNext"), SNAME("EditorIcons"))); - dobreak->set_icon(get_theme_icon(SNAME("Pause"), SNAME("EditorIcons"))); - docontinue->set_icon(get_theme_icon(SNAME("DebugContinue"), SNAME("EditorIcons"))); le_set->connect("pressed", callable_mp(this, &ScriptEditorDebugger::_live_edit_set)); 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)); + [[fallthrough]]; + } + case NOTIFICATION_THEME_CHANGED: { + skip_breakpoints->set_icon(get_theme_icon(skip_breakpoints_value ? SNAME("DebugSkipBreakpointsOn") : SNAME("DebugSkipBreakpointsOff"), SNAME("EditorIcons"))); + copy->set_icon(get_theme_icon(SNAME("ActionCopy"), SNAME("EditorIcons"))); + step->set_icon(get_theme_icon(SNAME("DebugStep"), SNAME("EditorIcons"))); + next->set_icon(get_theme_icon(SNAME("DebugNext"), SNAME("EditorIcons"))); + dobreak->set_icon(get_theme_icon(SNAME("Pause"), SNAME("EditorIcons"))); + 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"))); @@ -809,7 +812,7 @@ void ScriptEditorDebugger::_notification(int p_what) { Transform2D transform; transform.scale_basis(Size2(zoom, zoom)); - transform.elements[2] = -offset * zoom; + transform.columns[2] = -offset * zoom; Array msg; msg.push_back(transform); @@ -1047,10 +1050,10 @@ int ScriptEditorDebugger::_get_node_path_cache(const NodePath &p_path) { } int ScriptEditorDebugger::_get_res_path_cache(const String &p_path) { - Map<String, int>::Element *E = res_path_cache.find(p_path); + HashMap<String, int>::Iterator E = res_path_cache.find(p_path); if (E) { - return E->get(); + return E->value; } last_path_id++; @@ -1064,18 +1067,16 @@ int ScriptEditorDebugger::_get_res_path_cache(const String &p_path) { return last_path_id; } -void ScriptEditorDebugger::_method_changed(Object *p_base, const StringName &p_name, VARIANT_ARG_DECLARE) { +void ScriptEditorDebugger::_method_changed(Object *p_base, const StringName &p_name, const Variant **p_args, int p_argcount) { if (!p_base || !live_debug || !is_session_active() || !EditorNode::get_singleton()->get_edited_scene()) { return; } Node *node = Object::cast_to<Node>(p_base); - VARIANT_ARGPTRS - - for (int i = 0; i < VARIANT_ARG_MAX; i++) { + for (int i = 0; i < p_argcount; i++) { //no pointers, sorry - if (argptr[i] && (argptr[i]->get_type() == Variant::OBJECT || argptr[i]->get_type() == Variant::RID)) { + if (p_args[i]->get_type() == Variant::OBJECT || p_args[i]->get_type() == Variant::RID) { return; } } @@ -1087,9 +1088,9 @@ void ScriptEditorDebugger::_method_changed(Object *p_base, const StringName &p_n Array msg; msg.push_back(pathid); msg.push_back(p_name); - for (int i = 0; i < VARIANT_ARG_MAX; i++) { + for (int i = 0; i < p_argcount; i++) { //no pointers, sorry - msg.push_back(*argptr[i]); + msg.push_back(*p_args[i]); } _put_msg("scene:live_node_call", msg); @@ -1105,9 +1106,9 @@ void ScriptEditorDebugger::_method_changed(Object *p_base, const StringName &p_n Array msg; msg.push_back(pathid); msg.push_back(p_name); - for (int i = 0; i < VARIANT_ARG_MAX; i++) { + for (int i = 0; i < p_argcount; i++) { //no pointers, sorry - msg.push_back(*argptr[i]); + msg.push_back(*p_args[i]); } _put_msg("scene:live_res_call", msg); @@ -1464,6 +1465,7 @@ void ScriptEditorDebugger::_clear_errors_list() { error_tree->clear(); error_count = 0; warning_count = 0; + emit_signal(SNAME("errors_cleared")); update_tabs(); expand_all_button->set_disabled(true); @@ -1471,7 +1473,11 @@ void ScriptEditorDebugger::_clear_errors_list() { clear_button->set_disabled(true); } -void ScriptEditorDebugger::_breakpoints_item_rmb_selected(const Vector2 &p_pos) { +void ScriptEditorDebugger::_breakpoints_item_rmb_selected(const Vector2 &p_pos, MouseButton p_button) { + if (p_button != MouseButton::RIGHT) { + return; + } + breakpoints_menu->clear(); breakpoints_menu->set_size(Size2(1, 1)); @@ -1481,7 +1487,7 @@ void ScriptEditorDebugger::_breakpoints_item_rmb_selected(const Vector2 &p_pos) 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 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); @@ -1489,13 +1495,17 @@ void ScriptEditorDebugger::_breakpoints_item_rmb_selected(const Vector2 &p_pos) } // Right click on specific file(s) or folder(s). -void ScriptEditorDebugger::_error_tree_item_rmb_selected(const Vector2 &p_pos) { +void ScriptEditorDebugger::_error_tree_item_rmb_selected(const Vector2 &p_pos, MouseButton p_button) { + if (p_button != MouseButton::RIGHT) { + return; + } + item_menu->clear(); item_menu->reset_size(); if (error_tree->is_anything_selected()) { item_menu->add_icon_item(get_theme_icon(SNAME("ActionCopy"), SNAME("EditorIcons")), TTR("Copy Error"), ACTION_COPY_ERROR); - item_menu->add_icon_item(get_theme_icon(SNAME("Instance"), SNAME("EditorIcons")), TTR("Open C++ Source on GitHub"), ACTION_OPEN_SOURCE); + item_menu->add_icon_item(get_theme_icon(SNAME("ExternalLink"), SNAME("EditorIcons")), TTR("Open C++ Source on GitHub"), ACTION_OPEN_SOURCE); } if (item_menu->get_item_count() > 0) { @@ -1617,6 +1627,7 @@ void ScriptEditorDebugger::_bind_methods() { ADD_SIGNAL(MethodInfo("debug_data", PropertyInfo(Variant::STRING, "msg"), PropertyInfo(Variant::ARRAY, "data"))); ADD_SIGNAL(MethodInfo("set_breakpoint", PropertyInfo("script"), PropertyInfo(Variant::INT, "line"), PropertyInfo(Variant::BOOL, "enabled"))); ADD_SIGNAL(MethodInfo("clear_breakpoints")); + ADD_SIGNAL(MethodInfo("errors_cleared")); } void ScriptEditorDebugger::add_debugger_plugin(const Ref<Script> &p_script) { @@ -1658,7 +1669,6 @@ bool ScriptEditorDebugger::has_capture(const StringName &p_name) { ScriptEditorDebugger::ScriptEditorDebugger() { tabs = memnew(TabContainer); - tabs->set_tab_alignment(TabContainer::ALIGNMENT_LEFT); tabs->add_theme_style_override("panel", EditorNode::get_singleton()->get_gui_base()->get_theme_stylebox(SNAME("DebuggerPanel"), SNAME("EditorStyles"))); tabs->connect("tab_changed", callable_mp(this, &ScriptEditorDebugger::_tab_changed)); @@ -1757,14 +1767,14 @@ ScriptEditorDebugger::ScriptEditorDebugger() { search = memnew(LineEdit); search->set_h_size_flags(Control::SIZE_EXPAND_FILL); - search->set_placeholder(TTR("Filter stack variables")); + 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_property_name_style(EditorPropertyNameProcessor::STYLE_RAW); 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)); @@ -1780,7 +1790,7 @@ ScriptEditorDebugger::ScriptEditorDebugger() { 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->connect("item_mouse_selected", callable_mp(this, &ScriptEditorDebugger::_breakpoints_item_rmb_selected)); breakpoints_tree->create_item(); parent_sc->add_child(breakpoints_tree); @@ -1835,7 +1845,7 @@ ScriptEditorDebugger::ScriptEditorDebugger() { error_tree->set_hide_root(true); error_tree->set_v_size_flags(SIZE_EXPAND_FILL); error_tree->set_allow_rmb_select(true); - error_tree->connect("item_rmb_selected", callable_mp(this, &ScriptEditorDebugger::_error_tree_item_rmb_selected)); + error_tree->connect("item_mouse_selected", callable_mp(this, &ScriptEditorDebugger::_error_tree_item_rmb_selected)); errors_tab->add_child(error_tree); item_menu = memnew(PopupMenu); diff --git a/editor/debugger/script_editor_debugger.h b/editor/debugger/script_editor_debugger.h index e4d3a2fa09..aa0a50ff03 100644 --- a/editor/debugger/script_editor_debugger.h +++ b/editor/debugger/script_editor_debugger.h @@ -85,26 +85,26 @@ private: ACTION_DELETE_ALL_BREAKPOINTS, }; - AcceptDialog *msgdialog; - - LineEdit *clicked_ctrl; - LineEdit *clicked_ctrl_type; - LineEdit *live_edit_root; - Button *le_set; - Button *le_clear; - Button *export_csv; - - VBoxContainer *errors_tab; - Tree *error_tree; - Button *expand_all_button; - Button *collapse_all_button; - Button *clear_button; - PopupMenu *item_menu; - - Tree *breakpoints_tree; - PopupMenu *breakpoints_menu; - - EditorFileDialog *file_dialog; + AcceptDialog *msgdialog = nullptr; + + LineEdit *clicked_ctrl = nullptr; + LineEdit *clicked_ctrl_type = nullptr; + LineEdit *live_edit_root = nullptr; + Button *le_set = nullptr; + Button *le_clear = nullptr; + Button *export_csv = nullptr; + + VBoxContainer *errors_tab = nullptr; + Tree *error_tree = nullptr; + Button *expand_all_button = nullptr; + Button *collapse_all_button = nullptr; + Button *clear_button = nullptr; + PopupMenu *item_menu = nullptr; + + Tree *breakpoints_tree = nullptr; + PopupMenu *breakpoints_menu = nullptr; + + EditorFileDialog *file_dialog = nullptr; enum FileDialogPurpose { SAVE_MONITORS_CSV, SAVE_VRAM_CSV, @@ -117,42 +117,42 @@ private: bool skip_breakpoints_value = false; Ref<Script> stack_script; - TabContainer *tabs; + TabContainer *tabs = nullptr; - Label *reason; + Label *reason = nullptr; - Button *skip_breakpoints; - Button *copy; - Button *step; - Button *next; - Button *dobreak; - Button *docontinue; + Button *skip_breakpoints = nullptr; + Button *copy = nullptr; + Button *step = nullptr; + Button *next = nullptr; + Button *dobreak = nullptr; + Button *docontinue = nullptr; // Reference to "Remote" tab in scene tree. Needed by _live_edit_set and buttons state. // Each debugger should have it's tree in the future I guess. const Tree *editor_remote_tree = nullptr; - Map<int, String> profiler_signature; + HashMap<int, String> profiler_signature; - Tree *vmem_tree; - Button *vmem_refresh; - Button *vmem_export; - LineEdit *vmem_total; + Tree *vmem_tree = nullptr; + Button *vmem_refresh = nullptr; + Button *vmem_export = nullptr; + LineEdit *vmem_total = nullptr; - Tree *stack_dump; + Tree *stack_dump = nullptr; LineEdit *search = nullptr; - EditorDebuggerInspector *inspector; - SceneDebuggerTree *scene_tree; + EditorDebuggerInspector *inspector = nullptr; + SceneDebuggerTree *scene_tree = nullptr; Ref<RemoteDebuggerPeer> peer; HashMap<NodePath, int> node_path_cache; int last_path_id; - Map<String, int> res_path_cache; + HashMap<String, int> res_path_cache; - EditorProfiler *profiler; - EditorVisualProfiler *visual_profiler; - EditorNetworkProfiler *network_profiler; - EditorPerformanceProfiler *performance_profiler; + EditorProfiler *profiler = nullptr; + EditorVisualProfiler *visual_profiler = nullptr; + EditorNetworkProfiler *network_profiler = nullptr; + EditorPerformanceProfiler *performance_profiler = nullptr; OS::ProcessID remote_pid = 0; bool breaked = false; @@ -163,9 +163,9 @@ private: EditorDebuggerNode::CameraOverride camera_override; - Map<Ref<Script>, EditorDebuggerPlugin *> debugger_plugins; + HashMap<Ref<Script>, EditorDebuggerPlugin *> debugger_plugins; - Map<StringName, Callable> captures; + HashMap<StringName, Callable> captures; void _stack_dump_frame_selected(); @@ -187,7 +187,7 @@ private: void _live_edit_set(); void _live_edit_clear(); - void _method_changed(Object *p_base, const StringName &p_name, VARIANT_ARG_DECLARE); + void _method_changed(Object *p_base, const StringName &p_name, const Variant **p_args, int p_argcount); void _property_changed(Object *p_base, const StringName &p_property, const Variant &p_value); void _error_activated(); @@ -201,8 +201,8 @@ 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 _breakpoints_item_rmb_selected(const Vector2 &p_pos, MouseButton p_button); + void _error_tree_item_rmb_selected(const Vector2 &p_pos, MouseButton p_button); void _item_menu_id_pressed(int p_option); void _tab_changed(int p_tab); |