From 0be6d925dc3c6413bce7a3ccb49631b8e4a6e67a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Verschelde?= Date: Thu, 14 May 2020 13:23:58 +0200 Subject: Style: clang-format: Disable KeepEmptyLinesAtTheStartOfBlocks Which means that reduz' beloved style which we all became used to will now be changed automatically to remove the first empty line. This makes us lean closer to 1TBS (the one true brace style) instead of hybridating it with some Allman-inspired spacing. There's still the case of braces around single-statement blocks that needs to be addressed (but clang-format can't help with that, but clang-tidy may if we agree about it). Part of #33027. --- editor/dictionary_property_edit.cpp | 12 ------------ 1 file changed, 12 deletions(-) (limited to 'editor/dictionary_property_edit.cpp') diff --git a/editor/dictionary_property_edit.cpp b/editor/dictionary_property_edit.cpp index 7169986b14..c92f62cf58 100644 --- a/editor/dictionary_property_edit.cpp +++ b/editor/dictionary_property_edit.cpp @@ -40,12 +40,10 @@ void DictionaryPropertyEdit::_notif_changev(const String &p_v) { } void DictionaryPropertyEdit::_set_key(const Variant &p_old_key, const Variant &p_new_key) { - // TODO: Set key of a dictionary is not allowed yet } void DictionaryPropertyEdit::_set_value(const Variant &p_key, const Variant &p_value) { - Dictionary dict = get_dictionary(); dict[p_key] = p_value; Object *o = ObjectDB::get_instance(obj); @@ -56,7 +54,6 @@ void DictionaryPropertyEdit::_set_value(const Variant &p_key, const Variant &p_v } Variant DictionaryPropertyEdit::get_dictionary() const { - Object *o = ObjectDB::get_instance(obj); if (!o) return Dictionary(); @@ -67,7 +64,6 @@ Variant DictionaryPropertyEdit::get_dictionary() const { } void DictionaryPropertyEdit::_get_property_list(List *p_list) const { - Dictionary dict = get_dictionary(); Array keys = dict.keys(); @@ -87,13 +83,11 @@ void DictionaryPropertyEdit::_get_property_list(List *p_list) cons } void DictionaryPropertyEdit::edit(Object *p_obj, const StringName &p_prop) { - property = p_prop; obj = p_obj->get_instance_id(); } Node *DictionaryPropertyEdit::get_node() { - Object *o = ObjectDB::get_instance(obj); if (!o) return nullptr; @@ -106,7 +100,6 @@ bool DictionaryPropertyEdit::_dont_undo_redo() { } void DictionaryPropertyEdit::_bind_methods() { - ClassDB::bind_method(D_METHOD("_set_key"), &DictionaryPropertyEdit::_set_key); ClassDB::bind_method(D_METHOD("_set_value"), &DictionaryPropertyEdit::_set_value); ClassDB::bind_method(D_METHOD("_notif_change"), &DictionaryPropertyEdit::_notif_change); @@ -115,7 +108,6 @@ void DictionaryPropertyEdit::_bind_methods() { } bool DictionaryPropertyEdit::_set(const StringName &p_name, const Variant &p_value) { - Dictionary dict = get_dictionary(); Array keys = dict.keys(); keys.sort(); @@ -126,7 +118,6 @@ bool DictionaryPropertyEdit::_set(const StringName &p_name, const Variant &p_val String type = pn.substr(slash + 2, pn.length()); int index = pn.substr(0, slash).to_int(); if (type == "key" && index < keys.size()) { - const Variant &key = keys[index]; UndoRedo *ur = EditorNode::get_undo_redo(); @@ -141,7 +132,6 @@ bool DictionaryPropertyEdit::_set(const StringName &p_name, const Variant &p_val } else if (type == "value" && index < keys.size()) { const Variant &key = keys[index]; if (dict.has(key)) { - Variant value = dict[key]; UndoRedo *ur = EditorNode::get_undo_redo(); @@ -161,7 +151,6 @@ bool DictionaryPropertyEdit::_set(const StringName &p_name, const Variant &p_val } bool DictionaryPropertyEdit::_get(const StringName &p_name, Variant &r_ret) const { - Dictionary dict = get_dictionary(); Array keys = dict.keys(); keys.sort(); @@ -170,7 +159,6 @@ bool DictionaryPropertyEdit::_get(const StringName &p_name, Variant &r_ret) cons int slash = pn.find(": "); if (slash != -1 && pn.length() > slash) { - String type = pn.substr(slash + 2, pn.length()); int index = pn.substr(0, slash).to_int(); -- cgit v1.2.3 From 0ee0fa42e6639b6fa474b7cf6afc6b1a78142185 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Verschelde?= Date: Thu, 14 May 2020 16:41:43 +0200 Subject: 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 --- editor/dictionary_property_edit.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'editor/dictionary_property_edit.cpp') diff --git a/editor/dictionary_property_edit.cpp b/editor/dictionary_property_edit.cpp index c92f62cf58..276cd12ded 100644 --- a/editor/dictionary_property_edit.cpp +++ b/editor/dictionary_property_edit.cpp @@ -47,19 +47,22 @@ void DictionaryPropertyEdit::_set_value(const Variant &p_key, const Variant &p_v Dictionary dict = get_dictionary(); dict[p_key] = p_value; Object *o = ObjectDB::get_instance(obj); - if (!o) + if (!o) { return; + } o->set(property, dict); } Variant DictionaryPropertyEdit::get_dictionary() const { Object *o = ObjectDB::get_instance(obj); - if (!o) + if (!o) { return Dictionary(); + } Variant dict = o->get(property); - if (dict.get_type() != Variant::DICTIONARY) + if (dict.get_type() != Variant::DICTIONARY) { return Dictionary(); + } return dict; } @@ -89,8 +92,9 @@ void DictionaryPropertyEdit::edit(Object *p_obj, const StringName &p_prop) { Node *DictionaryPropertyEdit::get_node() { Object *o = ObjectDB::get_instance(obj); - if (!o) + if (!o) { return nullptr; + } return cast_to(o); } -- cgit v1.2.3