summaryrefslogtreecommitdiff
path: root/scene/debugger
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2020-05-14 16:41:43 +0200
committerRémi Verschelde <rverschelde@gmail.com>2020-05-14 21:57:34 +0200
commit0ee0fa42e6639b6fa474b7cf6afc6b1a78142185 (patch)
tree198d4ff7665d89307f6ca2469fa38620a9eb1672 /scene/debugger
parent07bc4e2f96f8f47991339654ff4ab16acc19d44f (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 'scene/debugger')
-rw-r--r--scene/debugger/scene_debugger.cpp210
1 files changed, 140 insertions, 70 deletions
diff --git a/scene/debugger/scene_debugger.cpp b/scene/debugger/scene_debugger.cpp
index 879f891cc9..0222585948 100644
--- a/scene/debugger/scene_debugger.cpp
+++ b/scene/debugger/scene_debugger.cpp
@@ -48,8 +48,9 @@ void SceneDebugger::deinitialize() {
#ifdef DEBUG_ENABLED
if (LiveEditor::singleton) {
// Should be removed automatically when deiniting debugger, but just in case
- if (EngineDebugger::has_capture("scene"))
+ if (EngineDebugger::has_capture("scene")) {
EngineDebugger::unregister_message_capture("scene");
+ }
memdelete(LiveEditor::singleton);
LiveEditor::singleton = nullptr;
}
@@ -59,11 +60,13 @@ void SceneDebugger::deinitialize() {
#ifdef DEBUG_ENABLED
Error SceneDebugger::parse_message(void *p_user, const String &p_msg, const Array &p_args, bool &r_captured) {
SceneTree *scene_tree = SceneTree::get_singleton();
- if (!scene_tree)
+ if (!scene_tree) {
return ERR_UNCONFIGURED;
+ }
LiveEditor *live_editor = LiveEditor::get_singleton();
- if (!live_editor)
+ if (!live_editor) {
return ERR_UNCONFIGURED;
+ }
r_captured = true;
if (p_msg == "request_scene_tree") { // Scene tree
@@ -193,8 +196,9 @@ void SceneDebugger::_save_node(ObjectID id, const String &p_path) {
void SceneDebugger::_send_object_id(ObjectID p_id, int p_max_size) {
SceneDebuggerObject obj(p_id);
- if (obj.id.is_null())
+ if (obj.id.is_null()) {
return;
+ }
Array arr;
obj.serialize(arr);
@@ -203,8 +207,9 @@ void SceneDebugger::_send_object_id(ObjectID p_id, int p_max_size) {
void SceneDebugger::_set_object_property(ObjectID p_id, const String &p_property, const Variant &p_value) {
Object *obj = ObjectDB::get_instance(p_id);
- if (!obj)
+ if (!obj) {
return;
+ }
String prop_name = p_property;
if (p_property.begins_with("Members/")) {
@@ -217,8 +222,9 @@ void SceneDebugger::_set_object_property(ObjectID p_id, const String &p_property
void SceneDebugger::add_to_cache(const String &p_filename, Node *p_node) {
LiveEditor *debugger = LiveEditor::get_singleton();
- if (!debugger)
+ if (!debugger) {
return;
+ }
if (EngineDebugger::get_script_debugger() && p_filename != String()) {
debugger->live_scene_edit_cache[p_filename].insert(p_node);
@@ -227,8 +233,9 @@ void SceneDebugger::add_to_cache(const String &p_filename, Node *p_node) {
void SceneDebugger::remove_from_cache(const String &p_filename, Node *p_node) {
LiveEditor *debugger = LiveEditor::get_singleton();
- if (!debugger)
+ if (!debugger) {
return;
+ }
Map<String, Set<Node *>> &edit_cache = debugger->live_scene_edit_cache;
Map<String, Set<Node *>>::Element *E = edit_cache.find(p_filename);
@@ -253,8 +260,9 @@ void SceneDebugger::remove_from_cache(const String &p_filename, Node *p_node) {
SceneDebuggerObject::SceneDebuggerObject(ObjectID p_id) {
id = ObjectID();
Object *obj = ObjectDB::get_instance(p_id);
- if (!obj)
+ if (!obj) {
return;
+ }
id = p_id;
class_name = obj->get_class();
@@ -483,8 +491,9 @@ LiveEditor *LiveEditor::get_singleton() {
void LiveEditor::_send_tree() {
SceneTree *scene_tree = SceneTree::get_singleton();
- if (!scene_tree)
+ if (!scene_tree) {
return;
+ }
Array arr;
// Encoded as a flat list depth fist.
@@ -503,29 +512,35 @@ void LiveEditor::_res_path_func(const String &p_path, int p_id) {
void LiveEditor::_node_set_func(int p_id, const StringName &p_prop, const Variant &p_value) {
SceneTree *scene_tree = SceneTree::get_singleton();
- if (!scene_tree)
+ if (!scene_tree) {
return;
+ }
- if (!live_edit_node_path_cache.has(p_id))
+ if (!live_edit_node_path_cache.has(p_id)) {
return;
+ }
NodePath np = live_edit_node_path_cache[p_id];
Node *base = nullptr;
- if (scene_tree->root->has_node(live_edit_root))
+ if (scene_tree->root->has_node(live_edit_root)) {
base = scene_tree->root->get_node(live_edit_root);
+ }
Map<String, Set<Node *>>::Element *E = live_scene_edit_cache.find(live_edit_scene);
- if (!E)
+ if (!E) {
return; //scene not editable
+ }
for (Set<Node *>::Element *F = E->get().front(); F; F = F->next()) {
Node *n = F->get();
- if (base && !base->is_a_parent_of(n))
+ if (base && !base->is_a_parent_of(n)) {
continue;
+ }
- if (!n->has_node(np))
+ if (!n->has_node(np)) {
continue;
+ }
Node *n2 = n->get_node(np);
n2->set(p_prop, p_value);
@@ -534,35 +549,42 @@ void LiveEditor::_node_set_func(int p_id, const StringName &p_prop, const Varian
void LiveEditor::_node_set_res_func(int p_id, const StringName &p_prop, const String &p_value) {
RES r = ResourceLoader::load(p_value);
- if (!r.is_valid())
+ if (!r.is_valid()) {
return;
+ }
_node_set_func(p_id, p_prop, r);
}
void LiveEditor::_node_call_func(int p_id, const StringName &p_method, VARIANT_ARG_DECLARE) {
SceneTree *scene_tree = SceneTree::get_singleton();
- if (!scene_tree)
+ if (!scene_tree) {
return;
- if (!live_edit_node_path_cache.has(p_id))
+ }
+ if (!live_edit_node_path_cache.has(p_id)) {
return;
+ }
NodePath np = live_edit_node_path_cache[p_id];
Node *base = nullptr;
- if (scene_tree->root->has_node(live_edit_root))
+ if (scene_tree->root->has_node(live_edit_root)) {
base = scene_tree->root->get_node(live_edit_root);
+ }
Map<String, Set<Node *>>::Element *E = live_scene_edit_cache.find(live_edit_scene);
- if (!E)
+ if (!E) {
return; //scene not editable
+ }
for (Set<Node *>::Element *F = E->get().front(); F; F = F->next()) {
Node *n = F->get();
- if (base && !base->is_a_parent_of(n))
+ if (base && !base->is_a_parent_of(n)) {
continue;
+ }
- if (!n->has_node(np))
+ if (!n->has_node(np)) {
continue;
+ }
Node *n2 = n->get_node(np);
n2->call(p_method, VARIANT_ARG_PASS);
@@ -570,40 +592,47 @@ void LiveEditor::_node_call_func(int p_id, const StringName &p_method, VARIANT_A
}
void LiveEditor::_res_set_func(int p_id, const StringName &p_prop, const Variant &p_value) {
- if (!live_edit_resource_cache.has(p_id))
+ if (!live_edit_resource_cache.has(p_id)) {
return;
+ }
String resp = live_edit_resource_cache[p_id];
- if (!ResourceCache::has(resp))
+ if (!ResourceCache::has(resp)) {
return;
+ }
RES r = ResourceCache::get(resp);
- if (!r.is_valid())
+ if (!r.is_valid()) {
return;
+ }
r->set(p_prop, p_value);
}
void LiveEditor::_res_set_res_func(int p_id, const StringName &p_prop, const String &p_value) {
RES r = ResourceLoader::load(p_value);
- if (!r.is_valid())
+ if (!r.is_valid()) {
return;
+ }
_res_set_func(p_id, p_prop, r);
}
void LiveEditor::_res_call_func(int p_id, const StringName &p_method, VARIANT_ARG_DECLARE) {
- if (!live_edit_resource_cache.has(p_id))
+ if (!live_edit_resource_cache.has(p_id)) {
return;
+ }
String resp = live_edit_resource_cache[p_id];
- if (!ResourceCache::has(resp))
+ if (!ResourceCache::has(resp)) {
return;
+ }
RES r = ResourceCache::get(resp);
- if (!r.is_valid())
+ if (!r.is_valid()) {
return;
+ }
r->call(p_method, VARIANT_ARG_PASS);
}
@@ -615,25 +644,30 @@ void LiveEditor::_root_func(const NodePath &p_scene_path, const String &p_scene_
void LiveEditor::_create_node_func(const NodePath &p_parent, const String &p_type, const String &p_name) {
SceneTree *scene_tree = SceneTree::get_singleton();
- if (!scene_tree)
+ if (!scene_tree) {
return;
+ }
Node *base = nullptr;
- if (scene_tree->root->has_node(live_edit_root))
+ if (scene_tree->root->has_node(live_edit_root)) {
base = scene_tree->root->get_node(live_edit_root);
+ }
Map<String, Set<Node *>>::Element *E = live_scene_edit_cache.find(live_edit_scene);
- if (!E)
+ if (!E) {
return; //scene not editable
+ }
for (Set<Node *>::Element *F = E->get().front(); F; F = F->next()) {
Node *n = F->get();
- if (base && !base->is_a_parent_of(n))
+ if (base && !base->is_a_parent_of(n)) {
continue;
+ }
- if (!n->has_node(p_parent))
+ if (!n->has_node(p_parent)) {
continue;
+ }
Node *n2 = n->get_node(p_parent);
Node *no = Object::cast_to<Node>(ClassDB::instance(p_type));
@@ -648,30 +682,36 @@ void LiveEditor::_create_node_func(const NodePath &p_parent, const String &p_typ
void LiveEditor::_instance_node_func(const NodePath &p_parent, const String &p_path, const String &p_name) {
SceneTree *scene_tree = SceneTree::get_singleton();
- if (!scene_tree)
+ if (!scene_tree) {
return;
+ }
Ref<PackedScene> ps = ResourceLoader::load(p_path);
- if (!ps.is_valid())
+ if (!ps.is_valid()) {
return;
+ }
Node *base = nullptr;
- if (scene_tree->root->has_node(live_edit_root))
+ if (scene_tree->root->has_node(live_edit_root)) {
base = scene_tree->root->get_node(live_edit_root);
+ }
Map<String, Set<Node *>>::Element *E = live_scene_edit_cache.find(live_edit_scene);
- if (!E)
+ if (!E) {
return; //scene not editable
+ }
for (Set<Node *>::Element *F = E->get().front(); F; F = F->next()) {
Node *n = F->get();
- if (base && !base->is_a_parent_of(n))
+ if (base && !base->is_a_parent_of(n)) {
continue;
+ }
- if (!n->has_node(p_parent))
+ if (!n->has_node(p_parent)) {
continue;
+ }
Node *n2 = n->get_node(p_parent);
Node *no = ps->instance();
@@ -686,27 +726,32 @@ void LiveEditor::_instance_node_func(const NodePath &p_parent, const String &p_p
void LiveEditor::_remove_node_func(const NodePath &p_at) {
SceneTree *scene_tree = SceneTree::get_singleton();
- if (!scene_tree)
+ if (!scene_tree) {
return;
+ }
Node *base = nullptr;
- if (scene_tree->root->has_node(live_edit_root))
+ if (scene_tree->root->has_node(live_edit_root)) {
base = scene_tree->root->get_node(live_edit_root);
+ }
Map<String, Set<Node *>>::Element *E = live_scene_edit_cache.find(live_edit_scene);
- if (!E)
+ if (!E) {
return; //scene not editable
+ }
for (Set<Node *>::Element *F = E->get().front(); F;) {
Set<Node *>::Element *N = F->next();
Node *n = F->get();
- if (base && !base->is_a_parent_of(n))
+ if (base && !base->is_a_parent_of(n)) {
continue;
+ }
- if (!n->has_node(p_at))
+ if (!n->has_node(p_at)) {
continue;
+ }
Node *n2 = n->get_node(p_at);
memdelete(n2);
@@ -717,27 +762,32 @@ void LiveEditor::_remove_node_func(const NodePath &p_at) {
void LiveEditor::_remove_and_keep_node_func(const NodePath &p_at, ObjectID p_keep_id) {
SceneTree *scene_tree = SceneTree::get_singleton();
- if (!scene_tree)
+ if (!scene_tree) {
return;
+ }
Node *base = nullptr;
- if (scene_tree->root->has_node(live_edit_root))
+ if (scene_tree->root->has_node(live_edit_root)) {
base = scene_tree->root->get_node(live_edit_root);
+ }
Map<String, Set<Node *>>::Element *E = live_scene_edit_cache.find(live_edit_scene);
- if (!E)
+ if (!E) {
return; //scene not editable
+ }
for (Set<Node *>::Element *F = E->get().front(); F;) {
Set<Node *>::Element *N = F->next();
Node *n = F->get();
- if (base && !base->is_a_parent_of(n))
+ if (base && !base->is_a_parent_of(n)) {
continue;
+ }
- if (!n->has_node(p_at))
+ if (!n->has_node(p_at)) {
continue;
+ }
Node *n2 = n->get_node(p_at);
@@ -751,38 +801,45 @@ void LiveEditor::_remove_and_keep_node_func(const NodePath &p_at, ObjectID p_kee
void LiveEditor::_restore_node_func(ObjectID p_id, const NodePath &p_at, int p_at_pos) {
SceneTree *scene_tree = SceneTree::get_singleton();
- if (!scene_tree)
+ if (!scene_tree) {
return;
+ }
Node *base = nullptr;
- if (scene_tree->root->has_node(live_edit_root))
+ if (scene_tree->root->has_node(live_edit_root)) {
base = scene_tree->root->get_node(live_edit_root);
+ }
Map<String, Set<Node *>>::Element *E = live_scene_edit_cache.find(live_edit_scene);
- if (!E)
+ if (!E) {
return; //scene not editable
+ }
for (Set<Node *>::Element *F = E->get().front(); F;) {
Set<Node *>::Element *N = F->next();
Node *n = F->get();
- if (base && !base->is_a_parent_of(n))
+ if (base && !base->is_a_parent_of(n)) {
continue;
+ }
- if (!n->has_node(p_at))
+ if (!n->has_node(p_at)) {
continue;
+ }
Node *n2 = n->get_node(p_at);
Map<Node *, Map<ObjectID, Node *>>::Element *EN = live_edit_remove_list.find(n);
- if (!EN)
+ if (!EN) {
continue;
+ }
Map<ObjectID, Node *>::Element *FN = EN->get().find(p_id);
- if (!FN)
+ if (!FN) {
continue;
+ }
n2->add_child(FN->get());
EN->get().erase(FN);
@@ -797,31 +854,37 @@ void LiveEditor::_restore_node_func(ObjectID p_id, const NodePath &p_at, int p_a
void LiveEditor::_duplicate_node_func(const NodePath &p_at, const String &p_new_name) {
SceneTree *scene_tree = SceneTree::get_singleton();
- if (!scene_tree)
+ if (!scene_tree) {
return;
+ }
Node *base = nullptr;
- if (scene_tree->root->has_node(live_edit_root))
+ if (scene_tree->root->has_node(live_edit_root)) {
base = scene_tree->root->get_node(live_edit_root);
+ }
Map<String, Set<Node *>>::Element *E = live_scene_edit_cache.find(live_edit_scene);
- if (!E)
+ if (!E) {
return; //scene not editable
+ }
for (Set<Node *>::Element *F = E->get().front(); F; F = F->next()) {
Node *n = F->get();
- if (base && !base->is_a_parent_of(n))
+ if (base && !base->is_a_parent_of(n)) {
continue;
+ }
- if (!n->has_node(p_at))
+ if (!n->has_node(p_at)) {
continue;
+ }
Node *n2 = n->get_node(p_at);
Node *dup = n2->duplicate(Node::DUPLICATE_SIGNALS | Node::DUPLICATE_GROUPS | Node::DUPLICATE_SCRIPTS);
- if (!dup)
+ if (!dup) {
continue;
+ }
dup->set_name(p_new_name);
n2->get_parent()->add_child(dup);
@@ -830,37 +893,44 @@ void LiveEditor::_duplicate_node_func(const NodePath &p_at, const String &p_new_
void LiveEditor::_reparent_node_func(const NodePath &p_at, const NodePath &p_new_place, const String &p_new_name, int p_at_pos) {
SceneTree *scene_tree = SceneTree::get_singleton();
- if (!scene_tree)
+ if (!scene_tree) {
return;
+ }
Node *base = nullptr;
- if (scene_tree->root->has_node(live_edit_root))
+ if (scene_tree->root->has_node(live_edit_root)) {
base = scene_tree->root->get_node(live_edit_root);
+ }
Map<String, Set<Node *>>::Element *E = live_scene_edit_cache.find(live_edit_scene);
- if (!E)
+ if (!E) {
return; //scene not editable
+ }
for (Set<Node *>::Element *F = E->get().front(); F; F = F->next()) {
Node *n = F->get();
- if (base && !base->is_a_parent_of(n))
+ if (base && !base->is_a_parent_of(n)) {
continue;
+ }
- if (!n->has_node(p_at))
+ if (!n->has_node(p_at)) {
continue;
+ }
Node *nfrom = n->get_node(p_at);
- if (!n->has_node(p_new_place))
+ if (!n->has_node(p_new_place)) {
continue;
+ }
Node *nto = n->get_node(p_new_place);
nfrom->get_parent()->remove_child(nfrom);
nfrom->set_name(p_new_name);
nto->add_child(nfrom);
- if (p_at_pos >= 0)
+ if (p_at_pos >= 0) {
nto->move_child(nfrom, p_at_pos);
+ }
}
}