diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2020-05-14 16:41:43 +0200 |
---|---|---|
committer | Rémi Verschelde <rverschelde@gmail.com> | 2020-05-14 21:57:34 +0200 |
commit | 0ee0fa42e6639b6fa474b7cf6afc6b1a78142185 (patch) | |
tree | 198d4ff7665d89307f6ca2469fa38620a9eb1672 /editor/debugger | |
parent | 07bc4e2f96f8f47991339654ff4ab16acc19d44f (diff) |
Style: Enforce braces around if blocks and loops
Using clang-tidy's `readability-braces-around-statements`.
https://clang.llvm.org/extra/clang-tidy/checks/readability-braces-around-statements.html
Diffstat (limited to 'editor/debugger')
-rw-r--r-- | editor/debugger/editor_debugger_inspector.cpp | 14 | ||||
-rw-r--r-- | editor/debugger/editor_debugger_node.cpp | 63 | ||||
-rw-r--r-- | editor/debugger/editor_debugger_node.h | 3 | ||||
-rw-r--r-- | editor/debugger/editor_debugger_tree.cpp | 18 | ||||
-rw-r--r-- | editor/debugger/editor_profiler.cpp | 50 | ||||
-rw-r--r-- | editor/debugger/editor_visual_profiler.cpp | 36 | ||||
-rw-r--r-- | editor/debugger/script_editor_debugger.cpp | 110 |
7 files changed, 194 insertions, 100 deletions
diff --git a/editor/debugger/editor_debugger_inspector.cpp b/editor/debugger/editor_debugger_inspector.cpp index 0c5fce91a6..125439d09b 100644 --- a/editor/debugger/editor_debugger_inspector.cpp +++ b/editor/debugger/editor_debugger_inspector.cpp @@ -36,8 +36,9 @@ #include "scene/debugger/scene_debugger.h" bool EditorDebuggerRemoteObject::_set(const StringName &p_name, const Variant &p_value) { - if (!editable || !prop_values.has(p_name) || String(p_name).begins_with("Constants/")) + if (!editable || !prop_values.has(p_name) || String(p_name).begins_with("Constants/")) { return false; + } prop_values[p_name] = p_value; emit_signal("value_edited", remote_object_id, p_name, p_value); @@ -45,8 +46,9 @@ bool EditorDebuggerRemoteObject::_set(const StringName &p_name, const Variant &p } bool EditorDebuggerRemoteObject::_get(const StringName &p_name, Variant &r_ret) const { - if (!prop_values.has(p_name)) + if (!prop_values.has(p_name)) { return false; + } r_ret = prop_values[p_name]; return true; @@ -60,10 +62,11 @@ void EditorDebuggerRemoteObject::_get_property_list(List<PropertyInfo> *p_list) } String EditorDebuggerRemoteObject::get_title() { - if (remote_object_id.is_valid()) + if (remote_object_id.is_valid()) { return TTR("Remote ") + String(type_name) + ": " + itos(remote_object_id); - else + } else { return "<null>"; + } } Variant EditorDebuggerRemoteObject::get_variant(const StringName &p_name) { @@ -211,8 +214,9 @@ void EditorDebuggerInspector::clear_cache() { } Object *EditorDebuggerInspector::get_object(ObjectID p_id) { - if (remote_objects.has(p_id)) + if (remote_objects.has(p_id)) { return remote_objects[p_id]; + } return nullptr; } diff --git a/editor/debugger/editor_debugger_node.cpp b/editor/debugger/editor_debugger_node.cpp index 76d1701372..a9c18138d8 100644 --- a/editor/debugger/editor_debugger_node.cpp +++ b/editor/debugger/editor_debugger_node.cpp @@ -50,8 +50,9 @@ void _for_all(TabContainer *p_node, const Func &p_func) { EditorDebuggerNode *EditorDebuggerNode::singleton = nullptr; EditorDebuggerNode::EditorDebuggerNode() { - if (!singleton) + if (!singleton) { singleton = this; + } add_theme_constant_override("margin_left", -EditorNode::get_singleton()->get_gui_base()->get_theme_stylebox("BottomPanelDebuggerOverride", "EditorStyles")->get_margin(MARGIN_LEFT)); add_theme_constant_override("margin_right", -EditorNode::get_singleton()->get_gui_base()->get_theme_stylebox("BottomPanelDebuggerOverride", "EditorStyles")->get_margin(MARGIN_RIGHT)); @@ -119,8 +120,9 @@ ScriptEditorDebugger *EditorDebuggerNode::_add_debugger() { void EditorDebuggerNode::_stack_frame_selected(int p_debugger) { const ScriptEditorDebugger *dbg = get_debugger(p_debugger); ERR_FAIL_COND(!dbg); - if (dbg != get_current_debugger()) + if (dbg != get_current_debugger()) { return; + } _text_editor_stack_goto(dbg); } @@ -131,8 +133,9 @@ 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(); - if (file.empty()) + if (file.empty()) { return; + } stack_script = ResourceLoader::load(file); const int line = p_debugger->get_stack_script_line() - 1; emit_signal("goto_script_line", stack_script, line); @@ -198,13 +201,15 @@ void EditorDebuggerNode::stop() { } // Also close all debugging sessions. _for_all(tabs, [&](ScriptEditorDebugger *dbg) { - if (dbg->is_session_active()) + if (dbg->is_session_active()) { dbg->stop(); + } }); _break_state_changed(); if (hide_on_stop) { - if (is_visible_in_tree()) + if (is_visible_in_tree()) { EditorNode::get_singleton()->hide_bottom_panel(); + } } breakpoints.clear(); set_process(false); @@ -224,8 +229,9 @@ void EditorDebuggerNode::_notification(int p_what) { break; } - if (p_what != NOTIFICATION_PROCESS || !server.is_valid()) + if (p_what != NOTIFICATION_PROCESS || !server.is_valid()) { return; + } if (!server.is_valid() || !server->is_active()) { stop(); @@ -285,8 +291,9 @@ void EditorDebuggerNode::_notification(int p_what) { if (server->is_connection_available()) { ScriptEditorDebugger *debugger = nullptr; _for_all(tabs, [&](ScriptEditorDebugger *dbg) { - if (debugger || dbg->is_session_active()) + if (debugger || dbg->is_session_active()) { return; + } debugger = dbg; }); if (debugger == nullptr) { @@ -325,8 +332,9 @@ void EditorDebuggerNode::_debugger_stopped(int p_id) { bool found = false; _for_all(tabs, [&](ScriptEditorDebugger *p_debugger) { - if (p_debugger->is_session_active()) + if (p_debugger->is_session_active()) { found = true; + } }); if (!found) { EditorNode::get_singleton()->get_pause_button()->set_pressed(false); @@ -340,8 +348,9 @@ void EditorDebuggerNode::_debugger_stopped(int p_id) { void EditorDebuggerNode::_debugger_wants_stop(int p_id) { // Ask editor to kill PID. int pid = get_debugger(p_id)->get_remote_pid(); - if (pid) + if (pid) { EditorNode::get_singleton()->call_deferred("stop_child_process", pid); + } } void EditorDebuggerNode::_debugger_changed(int p_tab) { @@ -380,12 +389,14 @@ void EditorDebuggerNode::set_script_debug_button(MenuButton *p_button) { void EditorDebuggerNode::_break_state_changed() { const bool breaked = get_current_debugger()->is_breaked(); const bool can_debug = get_current_debugger()->is_debuggable(); - if (breaked) // Show debugger. + if (breaked) { // Show debugger. EditorNode::get_singleton()->make_bottom_panel_item_visible(this); + } // Update script menu. - if (!script_menu) + if (!script_menu) { return; + } PopupMenu *p = script_menu->get_popup(); p->set_item_disabled(p->get_item_index(DEBUG_NEXT), !(breaked && can_debug)); p->set_item_disabled(p->get_item_index(DEBUG_STEP), !(breaked && can_debug)); @@ -434,8 +445,9 @@ void EditorDebuggerNode::_paused() { void EditorDebuggerNode::_breaked(bool p_breaked, bool p_can_debug, int p_debugger) { if (get_current_debugger() != get_debugger(p_debugger)) { - if (!p_breaked) + if (!p_breaked) { return; + } tabs->set_current_tab(p_debugger); } _break_state_changed(); @@ -486,58 +498,67 @@ void EditorDebuggerNode::request_remote_tree() { } void EditorDebuggerNode::_remote_tree_updated(int p_debugger) { - if (p_debugger != tabs->get_current_tab()) + if (p_debugger != tabs->get_current_tab()) { return; + } remote_scene_tree->clear(); remote_scene_tree->update_scene_tree(get_current_debugger()->get_remote_tree(), p_debugger); } void EditorDebuggerNode::_remote_object_updated(ObjectID p_id, int p_debugger) { - if (p_debugger != tabs->get_current_tab()) + if (p_debugger != tabs->get_current_tab()) { return; + } if (EditorDebuggerRemoteObject *obj = get_inspected_remote_object()) { - if (obj->remote_object_id == p_id) + if (obj->remote_object_id == p_id) { return; // Already being edited + } } EditorNode::get_singleton()->push_item(get_current_debugger()->get_remote_object(p_id)); } void EditorDebuggerNode::_remote_object_property_updated(ObjectID p_id, const String &p_property, int p_debugger) { - if (p_debugger != tabs->get_current_tab()) + if (p_debugger != tabs->get_current_tab()) { return; + } if (EditorDebuggerRemoteObject *obj = get_inspected_remote_object()) { - if (obj->remote_object_id != p_id) + if (obj->remote_object_id != p_id) { return; + } EditorNode::get_singleton()->get_inspector()->update_property(p_property); } } void EditorDebuggerNode::_remote_object_requested(ObjectID p_id, int p_debugger) { - if (p_debugger != tabs->get_current_tab()) + if (p_debugger != tabs->get_current_tab()) { return; + } inspect_edited_object_timeout = 0.7; // Temporarily disable timeout to avoid multiple requests. get_current_debugger()->request_remote_object(p_id); } void EditorDebuggerNode::_save_node_requested(ObjectID p_id, const String &p_file, int p_debugger) { - if (p_debugger != tabs->get_current_tab()) + if (p_debugger != tabs->get_current_tab()) { return; + } get_current_debugger()->save_node(p_id, p_file); } // Remote inspector/edit. void EditorDebuggerNode::_method_changeds(void *p_ud, Object *p_base, const StringName &p_name, VARIANT_ARG_DECLARE) { - if (!singleton) + if (!singleton) { return; + } _for_all(singleton->tabs, [&](ScriptEditorDebugger *dbg) { dbg->_method_changed(p_base, p_name, VARIANT_ARG_PASS); }); } void EditorDebuggerNode::_property_changeds(void *p_ud, Object *p_base, const StringName &p_property, const Variant &p_value) { - if (!singleton) + if (!singleton) { return; + } _for_all(singleton->tabs, [&](ScriptEditorDebugger *dbg) { dbg->_property_changed(p_base, p_property, p_value); }); diff --git a/editor/debugger/editor_debugger_node.h b/editor/debugger/editor_debugger_node.h index 9138651147..ff9601c026 100644 --- a/editor/debugger/editor_debugger_node.h +++ b/editor/debugger/editor_debugger_node.h @@ -70,8 +70,9 @@ private: int line = 0; bool operator<(const Breakpoint &p_b) const { - if (line == p_b.line) + if (line == p_b.line) { return source < p_b.source; + } return line < p_b.line; } diff --git a/editor/debugger/editor_debugger_tree.cpp b/editor/debugger/editor_debugger_tree.cpp index ecffa0f05d..0b5f865a98 100644 --- a/editor/debugger/editor_debugger_tree.cpp +++ b/editor/debugger/editor_debugger_tree.cpp @@ -84,8 +84,9 @@ void EditorDebuggerTree::_scene_tree_folded(Object *p_obj) { } TreeItem *item = Object::cast_to<TreeItem>(p_obj); - if (!item) + if (!item) { return; + } ObjectID id = ObjectID(uint64_t(item->get_metadata(0))); if (unfold_cache.has(id)) { @@ -97,8 +98,9 @@ void EditorDebuggerTree::_scene_tree_folded(Object *p_obj) { void EditorDebuggerTree::_scene_tree_rmb_selected(const Vector2 &p_position) { TreeItem *item = get_item_at_position(p_position); - if (!item) + if (!item) { return; + } item->select(0); @@ -176,12 +178,14 @@ 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_ofi(item->get_text(0))) { break; // Filter matches, must survive. + } parent->remove_child(item); memdelete(item); - if (had_siblings) + if (had_siblings) { break; // Parent must survive. + } item = parent; parent = item->get_parent(); // Check if parent expects more children. @@ -199,8 +203,9 @@ void EditorDebuggerTree::update_scene_tree(const SceneDebuggerTree *p_tree, int } String EditorDebuggerTree::get_selected_path() { - if (!get_selected()) + if (!get_selected()) { return ""; + } return _get_path(get_selected()); } @@ -256,7 +261,8 @@ void EditorDebuggerTree::_item_menu_id_pressed(int p_option) { } void EditorDebuggerTree::_file_selected(const String &p_file) { - if (inspected_object_id.is_null()) + if (inspected_object_id.is_null()) { return; + } emit_signal("save_node", inspected_object_id, p_file, debugger_id); } diff --git a/editor/debugger/editor_profiler.cpp b/editor/debugger/editor_profiler.cpp index 0b10602c54..8bd21fff5c 100644 --- a/editor/debugger/editor_profiler.cpp +++ b/editor/debugger/editor_profiler.cpp @@ -45,8 +45,9 @@ void EditorProfiler::_make_metric_ptrs(Metric &m) { void EditorProfiler::add_frame_metric(const Metric &p_metric, bool p_final) { ++last_metric; - if (last_metric >= frame_metrics.size()) + if (last_metric >= frame_metrics.size()) { last_metric = 0; + } frame_metrics.write[last_metric] = p_metric; _make_metric_ptrs(frame_metrics.write[last_metric]); @@ -134,19 +135,22 @@ Color EditorProfiler::_get_color_from_signature(const StringName &p_signature) c } void EditorProfiler::_item_edited() { - if (updating_frame) + if (updating_frame) { return; + } TreeItem *item = variables->get_edited(); - if (!item) + if (!item) { return; + } StringName signature = item->get_metadata(0); bool checked = item->is_checked(0); - if (checked) + if (checked) { plot_sigs.insert(signature); - else + } else { plot_sigs.erase(signature); + } if (!frame_delay->is_processing()) { frame_delay->set_wait_time(0.1); @@ -185,8 +189,9 @@ void EditorProfiler::_update_plot() { for (int i = 0; i < frame_metrics.size(); i++) { const Metric &m = frame_metrics[i]; - if (!m.valid) + if (!m.valid) { continue; + } 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()); @@ -228,8 +233,9 @@ void EditorProfiler::_update_plot() { if (next > frame_metrics.size()) { next = frame_metrics.size(); } - if (next == current) + if (next == current) { next = current + 1; //just because for loop must work + } for (Set<StringName>::Element *E = plot_sigs.front(); E; E = E->next()) { int plot_pos = -1; @@ -243,8 +249,9 @@ void EditorProfiler::_update_plot() { //get const Metric &m = frame_metrics[idx]; - if (!m.valid) + if (!m.valid) { continue; //skip because invalid + } float value = 0; @@ -423,13 +430,15 @@ void EditorProfiler::_notification(int p_what) { } void EditorProfiler::_graph_tex_draw() { - if (last_metric < 0) + if (last_metric < 0) { return; + } if (seeking) { int max_frames = frame_metrics.size(); int frame = cursor_metric_edit->get_value() - (frame_metrics[last_metric].frame_number - max_frames + 1); - if (frame < 0) + if (frame < 0) { frame = 0; + } int cur_x = frame * graph->get_size().x / max_frames; @@ -439,8 +448,9 @@ void EditorProfiler::_graph_tex_draw() { if (hover_metric != -1 && frame_metrics[hover_metric].valid) { int max_frames = frame_metrics.size(); int frame = frame_metrics[hover_metric].frame_number - (frame_metrics[last_metric].frame_number - max_frames + 1); - if (frame < 0) + if (frame < 0) { frame = 0; + } int cur_x = frame * graph->get_size().x / max_frames; @@ -454,16 +464,18 @@ void EditorProfiler::_graph_tex_mouse_exit() { } void EditorProfiler::_cursor_metric_changed(double) { - if (updating_frame) + if (updating_frame) { return; + } graph->update(); _update_frame(); } void EditorProfiler::_graph_tex_input(const Ref<InputEvent> &p_ev) { - if (last_metric < 0) + if (last_metric < 0) { return; + } Ref<InputEventMouse> me = p_ev; Ref<InputEventMouseButton> mb = p_ev; @@ -511,12 +523,14 @@ void EditorProfiler::_graph_tex_input(const Ref<InputEvent> &p_ev) { } metric++; - if (metric >= frame_metrics.size()) + if (metric >= frame_metrics.size()) { metric = 0; + } } - if (valid) + if (valid) { cursor_metric_edit->set_value(frame_metrics[metric].frame_number); + } updating_frame = false; @@ -539,10 +553,12 @@ void EditorProfiler::_graph_tex_input(const Ref<InputEvent> &p_ev) { } int EditorProfiler::_get_cursor_index() const { - if (last_metric < 0) + if (last_metric < 0) { return 0; - if (!frame_metrics[last_metric].valid) + } + if (!frame_metrics[last_metric].valid) { return 0; + } int diff = (frame_metrics[last_metric].frame_number - cursor_metric_edit->get_value()); diff --git a/editor/debugger/editor_visual_profiler.cpp b/editor/debugger/editor_visual_profiler.cpp index e1bd00f6f6..81b42da08e 100644 --- a/editor/debugger/editor_visual_profiler.cpp +++ b/editor/debugger/editor_visual_profiler.cpp @@ -36,8 +36,9 @@ void EditorVisualProfiler::add_frame_metric(const Metric &p_metric) { ++last_metric; - if (last_metric >= frame_metrics.size()) + if (last_metric >= frame_metrics.size()) { last_metric = 0; + } frame_metrics.write[last_metric] = p_metric; // _make_metric_ptrs(frame_metrics.write[last_metric]); @@ -130,12 +131,14 @@ Color EditorVisualProfiler::_get_color_from_signature(const StringName &p_signat } void EditorVisualProfiler::_item_selected() { - if (updating_frame) + if (updating_frame) { return; + } TreeItem *item = variables->get_selected(); - if (!item) + if (!item) { return; + } selected_area = item->get_metadata(0); _update_plot(); } @@ -170,8 +173,9 @@ void EditorVisualProfiler::_update_plot() { for (int i = 0; i < frame_metrics.size(); i++) { const Metric &m = frame_metrics[i]; - if (!m.valid) + if (!m.valid) { continue; + } if (m.areas.size()) { highest_cpu = MAX(highest_cpu, m.areas[m.areas.size() - 1].cpu_time); @@ -216,8 +220,9 @@ void EditorVisualProfiler::_update_plot() { if (next > frame_metrics.size()) { next = frame_metrics.size(); } - if (next == current) + if (next == current) { next = current + 1; //just because for loop must work + } for (int j = current; j < next; j++) { //wrap @@ -425,14 +430,16 @@ void EditorVisualProfiler::_notification(int p_what) { } void EditorVisualProfiler::_graph_tex_draw() { - if (last_metric < 0) + if (last_metric < 0) { return; + } Ref<Font> font = get_theme_font("font", "Label"); if (seeking) { int max_frames = frame_metrics.size(); int frame = cursor_metric_edit->get_value() - (frame_metrics[last_metric].frame_number - max_frames + 1); - if (frame < 0) + if (frame < 0) { frame = 0; + } int half_width = graph->get_size().x / 2; int cur_x = frame * half_width / max_frames; @@ -488,16 +495,18 @@ void EditorVisualProfiler::_graph_tex_mouse_exit() { } void EditorVisualProfiler::_cursor_metric_changed(double) { - if (updating_frame) + if (updating_frame) { return; + } graph->update(); _update_frame(); } void EditorVisualProfiler::_graph_tex_input(const Ref<InputEvent> &p_ev) { - if (last_metric < 0) + if (last_metric < 0) { return; + } Ref<InputEventMouse> me = p_ev; Ref<InputEventMouseButton> mb = p_ev; @@ -549,8 +558,9 @@ void EditorVisualProfiler::_graph_tex_input(const Ref<InputEvent> &p_ev) { } metric++; - if (metric >= frame_metrics.size()) + if (metric >= frame_metrics.size()) { metric = 0; + } } if (!valid) { @@ -610,10 +620,12 @@ void EditorVisualProfiler::_graph_tex_input(const Ref<InputEvent> &p_ev) { } int EditorVisualProfiler::_get_cursor_index() const { - if (last_metric < 0) + if (last_metric < 0) { return 0; - if (!frame_metrics[last_metric].valid) + } + if (!frame_metrics[last_metric].valid) { return 0; + } int diff = (frame_metrics[last_metric].frame_number - cursor_metric_edit->get_value()); diff --git a/editor/debugger/script_editor_debugger.cpp b/editor/debugger/script_editor_debugger.cpp index 867eef1c93..49137f76fa 100644 --- a/editor/debugger/script_editor_debugger.cpp +++ b/editor/debugger/script_editor_debugger.cpp @@ -74,17 +74,19 @@ void ScriptEditorDebugger::_put_msg(String p_message, Array p_data) { void ScriptEditorDebugger::debug_copy() { String msg = reason->get_text(); - if (msg == "") + if (msg == "") { return; + } DisplayServer::get_singleton()->clipboard_set(msg); } void ScriptEditorDebugger::debug_skip_breakpoints() { skip_breakpoints_value = !skip_breakpoints_value; - if (skip_breakpoints_value) + if (skip_breakpoints_value) { skip_breakpoints->set_icon(get_theme_icon("DebugSkipBreakpointsOn", "EditorIcons")); - else + } else { skip_breakpoints->set_icon(get_theme_icon("DebugSkipBreakpointsOff", "EditorIcons")); + } Array msg; msg.push_back(skip_breakpoints_value); @@ -115,8 +117,9 @@ void ScriptEditorDebugger::debug_continue() { ERR_FAIL_COND(!breaked); // Allow focus stealing only if we actually run this client for security. - if (remote_pid && EditorNode::get_singleton()->has_child_process(remote_pid)) + if (remote_pid && EditorNode::get_singleton()->has_child_process(remote_pid)) { DisplayServer::get_singleton()->enable_for_stealing_focus(remote_pid); + } _clear_execution(); _put_msg("continue", Array()); @@ -318,8 +321,9 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, const Array &p_da _update_buttons_state(); } else if (p_msg == "scene:inspect_object") { ObjectID id = inspector->add_object(p_data); - if (id.is_valid()) + if (id.is_valid()) { emit_signal("remote_object_updated", id); + } } else if (p_msg == "memory:usage") { vmem_tree->clear(); TreeItem *root = vmem_tree->create_item(); @@ -338,8 +342,9 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, const Array &p_da it->set_text(3, String::humanize_size(bytes)); total += bytes; - if (has_theme_icon(type, "EditorIcons")) + if (has_theme_icon(type, "EditorIcons")) { it->set_icon(0, get_theme_icon(type, "EditorIcons")); + } } vmem_total->set_tooltip(TTR("Bytes:") + " " + itos(total)); @@ -365,8 +370,9 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, const Array &p_da String line = itos(i) + " - " + String(d["file"]) + ":" + itos(d["line"]) + " - at function: " + d["function"]; s->set_text(0, line); - if (i == 0) + if (i == 0) { s->select(0); + } } } else if (p_msg == "stack_frame_vars") { inspector->clear_stack_variables(); @@ -427,8 +433,9 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, const Array &p_da perf_items[i]->set_text(1, label); perf_items[i]->set_tooltip(1, tooltip); - if (p[i] > perf_max[i]) + if (p[i] > perf_max[i]) { perf_max.write[i] = p[i]; + } } } perf_history.push_front(p); @@ -493,8 +500,9 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, const Array &p_da String error_title; // Include method name, when given, in error title. - if (!oe.source_func.empty()) + if (!oe.source_func.empty()) { error_title += oe.source_func + ": "; + } // If we have a (custom) error message, use it as title, and add a C++ Error // item with the original error condition. error_title += oe.error_descr.empty() ? oe.error : oe.error_descr; @@ -508,16 +516,18 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, const Array &p_da cpp_cond->set_text(1, oe.error); cpp_cond->set_text_align(0, TreeItem::ALIGN_LEFT); tooltip += TTR("C++ Error:") + " " + oe.error + "\n"; - if (source_is_project_file) + if (source_is_project_file) { cpp_cond->set_metadata(0, source_meta); + } } Vector<uint8_t> v; v.resize(100); // Source of the error. String source_txt = (source_is_project_file ? oe.source_file.get_file() : oe.source_file) + ":" + itos(oe.source_line); - if (!oe.source_func.empty()) + if (!oe.source_func.empty()) { source_txt += " @ " + oe.source_func + "()"; + } TreeItem *cpp_source = error_tree->create_item(error); cpp_source->set_text(0, "<" + (source_is_project_file ? TTR("Source") : TTR("C++ Source")) + ">"); @@ -554,10 +564,11 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, const Array &p_da stack_trace->set_text(1, infos[i].file.get_file() + ":" + itos(infos[i].line) + " @ " + infos[i].func + "()"); } - if (oe.warning) + if (oe.warning) { warning_count++; - else + } else { error_count++; + } } else if (p_msg == "servers:function_signature") { // Cache a profiler signature. @@ -672,10 +683,11 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, const Array &p_da metric.categories.push_back(funcs); - if (p_msg == "servers:profile_frame") + if (p_msg == "servers:profile_frame") { profiler->add_frame_metric(metric, false); - else + } else { profiler->add_frame_metric(metric, true); + } } else if (p_msg == "network:profile_frame") { DebuggerMarshalls::NetworkProfilerFrame frame; @@ -719,8 +731,9 @@ void ScriptEditorDebugger::_performance_select() { void ScriptEditorDebugger::_performance_draw() { Vector<int> which; for (int i = 0; i < perf_items.size(); i++) { - if (perf_items[i]->is_checked(0)) + if (perf_items[i]->is_checked(0)) { which.push_back(i); + } } if (which.empty()) { @@ -735,8 +748,9 @@ void ScriptEditorDebugger::_performance_draw() { int cols = Math::ceil(Math::sqrt((float)which.size())); int rows = Math::ceil((float)which.size() / cols); - if (which.size() == 1) + if (which.size() == 1) { rows = 1; + } int margin = 3; int point_sep = 5; @@ -768,13 +782,15 @@ void ScriptEditorDebugger::_performance_draw() { float prev = -1; while (from >= 0 && E) { float m = perf_max[pi]; - if (m == 0) + if (m == 0) { m = 0.00001; + } float h2 = E->get()[pi] / m; h2 = (1.0 - h2) * r.size.y; - if (E != perf_history.front()) + if (E != perf_history.front()) { perf_draw->draw_line(r.position + Point2(from, h2), r.position + Point2(from + spacing, prev), c, Math::round(EDSCALE)); + } prev = h2; E = E->next(); from -= spacing; @@ -851,8 +867,9 @@ void ScriptEditorDebugger::_notification(int p_what) { } _parse_message(arr[0], arr[1]); - if (OS::get_singleton()->get_ticks_msec() > until) + if (OS::get_singleton()->get_ticks_msec() > until) { break; + } } if (!is_session_active()) { _stop_and_notify(); @@ -877,8 +894,9 @@ void ScriptEditorDebugger::_notification(int p_what) { void ScriptEditorDebugger::_clear_execution() { TreeItem *ti = stack_dump->get_selected(); - if (!ti) + if (!ti) { return; + } Dictionary d = ti->get_metadata(0); @@ -983,8 +1001,9 @@ void ScriptEditorDebugger::_profiler_activate(bool p_enable, int p_type) { } void ScriptEditorDebugger::_profiler_seeked() { - if (breaked) + if (breaked) { return; + } debug_break(); } @@ -1010,15 +1029,17 @@ void ScriptEditorDebugger::_export_csv() { } String ScriptEditorDebugger::get_var_value(const String &p_var) const { - if (!breaked) + if (!breaked) { return String(); + } return inspector->get_stack_variable(p_var); } int ScriptEditorDebugger::_get_node_path_cache(const NodePath &p_path) { const int *r = node_path_cache.getptr(p_path); - if (r) + if (r) { return *r; + } last_path_id++; @@ -1034,8 +1055,9 @@ 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); - if (E) + if (E) { return E->get(); + } last_path_id++; @@ -1049,8 +1071,9 @@ int ScriptEditorDebugger::_get_res_path_cache(const String &p_path) { } void ScriptEditorDebugger::_method_changed(Object *p_base, const StringName &p_name, VARIANT_ARG_DECLARE) { - if (!p_base || !live_debug || !is_session_active() || !editor->get_edited_scene()) + if (!p_base || !live_debug || !is_session_active() || !editor->get_edited_scene()) { return; + } Node *node = Object::cast_to<Node>(p_base); @@ -1058,8 +1081,9 @@ void ScriptEditorDebugger::_method_changed(Object *p_base, const StringName &p_n for (int i = 0; i < VARIANT_ARG_MAX; i++) { //no pointers, sorry - if (argptr[i] && (argptr[i]->get_type() == Variant::OBJECT || argptr[i]->get_type() == Variant::_RID)) + if (argptr[i] && (argptr[i]->get_type() == Variant::OBJECT || argptr[i]->get_type() == Variant::_RID)) { return; + } } if (node) { @@ -1098,8 +1122,9 @@ void ScriptEditorDebugger::_method_changed(Object *p_base, const StringName &p_n } void ScriptEditorDebugger::_property_changed(Object *p_base, const StringName &p_property, const Variant &p_value) { - if (!p_base || !live_debug || !editor->get_edited_scene()) + if (!p_base || !live_debug || !editor->get_edited_scene()) { return; + } Node *node = Object::cast_to<Node>(p_base); @@ -1156,24 +1181,27 @@ void ScriptEditorDebugger::_property_changed(Object *p_base, const StringName &p String ScriptEditorDebugger::get_stack_script_file() const { TreeItem *ti = stack_dump->get_selected(); - if (!ti) + if (!ti) { return ""; + } Dictionary d = ti->get_metadata(0); return d["file"]; } int ScriptEditorDebugger::get_stack_script_line() const { TreeItem *ti = stack_dump->get_selected(); - if (!ti) + if (!ti) { return -1; + } Dictionary d = ti->get_metadata(0); return d["line"]; } int ScriptEditorDebugger::get_stack_script_frame() const { TreeItem *ti = stack_dump->get_selected(); - if (!ti) + if (!ti) { return -1; + } Dictionary d = ti->get_metadata(0); return d["frame"]; } @@ -1183,12 +1211,14 @@ void ScriptEditorDebugger::set_live_debugging(bool p_enable) { } void ScriptEditorDebugger::_live_edit_set() { - if (!is_session_active() || !editor_remote_tree) + if (!is_session_active() || !editor_remote_tree) { return; + } TreeItem *ti = editor_remote_tree->get_selected(); - if (!ti) + if (!ti) { return; + } String path; @@ -1217,10 +1247,11 @@ void ScriptEditorDebugger::update_live_edit_root() { Array msg; msg.push_back(np); - if (editor->get_edited_scene()) + if (editor->get_edited_scene()) { msg.push_back(editor->get_edited_scene()->get_filename()); - else + } else { msg.push_back(""); + } _put_msg("scene:live_set_root", msg); live_edit_root->set_text(np); } @@ -1355,8 +1386,9 @@ void ScriptEditorDebugger::_error_selected() { void ScriptEditorDebugger::_expand_errors_list() { TreeItem *root = error_tree->get_root(); - if (!root) + if (!root) { return; + } TreeItem *item = root->get_children(); while (item) { @@ -1367,8 +1399,9 @@ void ScriptEditorDebugger::_expand_errors_list() { void ScriptEditorDebugger::_collapse_errors_list() { TreeItem *root = error_tree->get_root(); - if (!root) + if (!root) { return; + } TreeItem *item = root->get_children(); while (item) { @@ -1400,8 +1433,9 @@ void ScriptEditorDebugger::_error_tree_item_rmb_selected(const Vector2 &p_pos) { void ScriptEditorDebugger::_item_menu_id_pressed(int p_option) { TreeItem *ti = error_tree->get_selected(); - while (ti->get_parent() != error_tree->get_root()) + while (ti->get_parent() != error_tree->get_root()) { ti = ti->get_parent(); + } String type; |