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
This commit is contained in:
+83
-45
@@ -52,8 +52,9 @@ void ProjectExportDialog::_theme_changed() {
|
||||
duplicate_preset->set_icon(presets->get_theme_icon("Duplicate", "EditorIcons"));
|
||||
delete_preset->set_icon(presets->get_theme_icon("Remove", "EditorIcons"));
|
||||
Control *panel = custom_feature_display->get_parent_control();
|
||||
if (panel)
|
||||
if (panel) {
|
||||
panel->add_theme_style_override("panel", patches->get_theme_stylebox("bg", "Tree"));
|
||||
}
|
||||
}
|
||||
|
||||
void ProjectExportDialog::_notification(int p_what) {
|
||||
@@ -115,16 +116,18 @@ void ProjectExportDialog::_add_preset(int p_platform) {
|
||||
}
|
||||
}
|
||||
|
||||
if (valid)
|
||||
if (valid) {
|
||||
break;
|
||||
}
|
||||
|
||||
attempt++;
|
||||
name = EditorExport::get_singleton()->get_export_platform(p_platform)->get_name() + " " + itos(attempt);
|
||||
}
|
||||
|
||||
preset->set_name(name);
|
||||
if (make_runnable)
|
||||
if (make_runnable) {
|
||||
preset->set_runnable(make_runnable);
|
||||
}
|
||||
EditorExport::get_singleton()->add_export_preset(preset);
|
||||
_update_presets();
|
||||
_edit_preset(EditorExport::get_singleton()->get_export_preset_count() - 1);
|
||||
@@ -138,8 +141,9 @@ void ProjectExportDialog::_update_presets() {
|
||||
updating = true;
|
||||
|
||||
Ref<EditorExportPreset> current;
|
||||
if (presets->get_current() >= 0 && presets->get_current() < presets->get_item_count())
|
||||
if (presets->get_current() >= 0 && presets->get_current() < presets->get_item_count()) {
|
||||
current = get_current_preset();
|
||||
}
|
||||
|
||||
int current_idx = -1;
|
||||
presets->clear();
|
||||
@@ -150,8 +154,9 @@ void ProjectExportDialog::_update_presets() {
|
||||
}
|
||||
|
||||
String name = preset->get_name();
|
||||
if (preset->is_runnable())
|
||||
if (preset->is_runnable()) {
|
||||
name += " (" + TTR("Runnable") + ")";
|
||||
}
|
||||
presets->add_item(name, preset->get_platform()->get_logo());
|
||||
}
|
||||
|
||||
@@ -238,8 +243,9 @@ void ProjectExportDialog::_edit_preset(int p_index) {
|
||||
String file = patchlist[i].get_file();
|
||||
patch->set_editable(0, true);
|
||||
patch->set_text(0, file.get_file().replace("*", ""));
|
||||
if (file.ends_with("*"))
|
||||
if (file.ends_with("*")) {
|
||||
patch->set_checked(0, true);
|
||||
}
|
||||
patch->set_tooltip(0, patchlist[i]);
|
||||
patch->set_metadata(0, i);
|
||||
patch->add_button(0, presets->get_theme_icon("Remove", "EditorIcons"), 0);
|
||||
@@ -248,10 +254,11 @@ void ProjectExportDialog::_edit_preset(int p_index) {
|
||||
|
||||
TreeItem *patch_add = patches->create_item(patch_root);
|
||||
patch_add->set_metadata(0, patchlist.size());
|
||||
if (patchlist.size() == 0)
|
||||
if (patchlist.size() == 0) {
|
||||
patch_add->set_text(0, TTR("Add initial export..."));
|
||||
else
|
||||
} else {
|
||||
patch_add->set_text(0, TTR("Add previous patches..."));
|
||||
}
|
||||
|
||||
patch_add->add_button(0, presets->get_theme_icon("folder", "FileDialog"), 1);
|
||||
|
||||
@@ -264,8 +271,9 @@ void ProjectExportDialog::_edit_preset(int p_index) {
|
||||
Vector<String> items = error.split("\n", false);
|
||||
error = "";
|
||||
for (int i = 0; i < items.size(); i++) {
|
||||
if (i > 0)
|
||||
if (i > 0) {
|
||||
error += "\n";
|
||||
}
|
||||
error += " - " + items[i];
|
||||
}
|
||||
|
||||
@@ -274,10 +282,11 @@ void ProjectExportDialog::_edit_preset(int p_index) {
|
||||
} else {
|
||||
export_error->hide();
|
||||
}
|
||||
if (needs_templates)
|
||||
if (needs_templates) {
|
||||
export_templates_error->show();
|
||||
else
|
||||
} else {
|
||||
export_templates_error->hide();
|
||||
}
|
||||
|
||||
export_button->set_disabled(true);
|
||||
get_ok()->set_disabled(true);
|
||||
@@ -352,8 +361,9 @@ void ProjectExportDialog::_update_feature_list() {
|
||||
}
|
||||
|
||||
void ProjectExportDialog::_custom_features_changed(const String &p_text) {
|
||||
if (updating)
|
||||
if (updating) {
|
||||
return;
|
||||
}
|
||||
|
||||
Ref<EditorExportPreset> current = get_current_preset();
|
||||
ERR_FAIL_COND(current.is_null());
|
||||
@@ -386,8 +396,9 @@ void ProjectExportDialog::_patch_button_pressed(Object *p_item, int p_column, in
|
||||
|
||||
void ProjectExportDialog::_patch_edited() {
|
||||
TreeItem *item = patches->get_edited();
|
||||
if (!item)
|
||||
if (!item) {
|
||||
return;
|
||||
}
|
||||
int index = item->get_metadata(0);
|
||||
|
||||
Ref<EditorExportPreset> current = get_current_preset();
|
||||
@@ -438,8 +449,9 @@ void ProjectExportDialog::_update_parameters(const String &p_edited_property) {
|
||||
}
|
||||
|
||||
void ProjectExportDialog::_runnable_pressed() {
|
||||
if (updating)
|
||||
if (updating) {
|
||||
return;
|
||||
}
|
||||
|
||||
Ref<EditorExportPreset> current = get_current_preset();
|
||||
ERR_FAIL_COND(current.is_null());
|
||||
@@ -459,8 +471,9 @@ void ProjectExportDialog::_runnable_pressed() {
|
||||
}
|
||||
|
||||
void ProjectExportDialog::_name_changed(const String &p_string) {
|
||||
if (updating)
|
||||
if (updating) {
|
||||
return;
|
||||
}
|
||||
|
||||
Ref<EditorExportPreset> current = get_current_preset();
|
||||
ERR_FAIL_COND(current.is_null());
|
||||
@@ -488,8 +501,9 @@ Ref<EditorExportPreset> ProjectExportDialog::get_current_preset() const {
|
||||
}
|
||||
|
||||
void ProjectExportDialog::_export_path_changed(const StringName &p_property, const Variant &p_value, const String &p_field, bool p_changing) {
|
||||
if (updating)
|
||||
if (updating) {
|
||||
return;
|
||||
}
|
||||
|
||||
Ref<EditorExportPreset> current = get_current_preset();
|
||||
ERR_FAIL_COND(current.is_null());
|
||||
@@ -499,8 +513,9 @@ void ProjectExportDialog::_export_path_changed(const StringName &p_property, con
|
||||
}
|
||||
|
||||
void ProjectExportDialog::_script_export_mode_changed(int p_mode) {
|
||||
if (updating)
|
||||
if (updating) {
|
||||
return;
|
||||
}
|
||||
|
||||
Ref<EditorExportPreset> current = get_current_preset();
|
||||
ERR_FAIL_COND(current.is_null());
|
||||
@@ -511,8 +526,9 @@ void ProjectExportDialog::_script_export_mode_changed(int p_mode) {
|
||||
}
|
||||
|
||||
void ProjectExportDialog::_script_encryption_key_changed(const String &p_key) {
|
||||
if (updating)
|
||||
if (updating) {
|
||||
return;
|
||||
}
|
||||
|
||||
Ref<EditorExportPreset> current = get_current_preset();
|
||||
ERR_FAIL_COND(current.is_null());
|
||||
@@ -535,8 +551,9 @@ bool ProjectExportDialog::_validate_script_encryption_key(const String &p_key) {
|
||||
|
||||
void ProjectExportDialog::_duplicate_preset() {
|
||||
Ref<EditorExportPreset> current = get_current_preset();
|
||||
if (current.is_null())
|
||||
if (current.is_null()) {
|
||||
return;
|
||||
}
|
||||
|
||||
Ref<EditorExportPreset> preset = current->get_platform()->create_preset();
|
||||
ERR_FAIL_COND(!preset.is_valid());
|
||||
@@ -557,15 +574,17 @@ void ProjectExportDialog::_duplicate_preset() {
|
||||
}
|
||||
}
|
||||
|
||||
if (valid)
|
||||
if (valid) {
|
||||
break;
|
||||
}
|
||||
|
||||
name += " (copy)";
|
||||
}
|
||||
|
||||
preset->set_name(name);
|
||||
if (make_runnable)
|
||||
if (make_runnable) {
|
||||
preset->set_runnable(make_runnable);
|
||||
}
|
||||
preset->set_export_filter(current->get_export_filter());
|
||||
preset->set_include_filter(current->get_include_filter());
|
||||
preset->set_exclude_filter(current->get_exclude_filter());
|
||||
@@ -586,8 +605,9 @@ void ProjectExportDialog::_duplicate_preset() {
|
||||
|
||||
void ProjectExportDialog::_delete_preset() {
|
||||
Ref<EditorExportPreset> current = get_current_preset();
|
||||
if (current.is_null())
|
||||
if (current.is_null()) {
|
||||
return;
|
||||
}
|
||||
|
||||
delete_confirm->set_text(vformat(TTR("Delete preset '%s'?"), current->get_name()));
|
||||
delete_confirm->popup_centered();
|
||||
@@ -646,15 +666,18 @@ Variant ProjectExportDialog::get_drag_data_fw(const Point2 &p_point, Control *p_
|
||||
bool ProjectExportDialog::can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const {
|
||||
if (p_from == presets) {
|
||||
Dictionary d = p_data;
|
||||
if (!d.has("type") || String(d["type"]) != "export_preset")
|
||||
if (!d.has("type") || String(d["type"]) != "export_preset") {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (presets->get_item_at_position(p_point, true) < 0 && !presets->is_pos_at_end_of_items(p_point))
|
||||
if (presets->get_item_at_position(p_point, true) < 0 && !presets->is_pos_at_end_of_items(p_point)) {
|
||||
return false;
|
||||
}
|
||||
} else if (p_from == patches) {
|
||||
Dictionary d = p_data;
|
||||
if (!d.has("type") || String(d["type"]) != "export_patch")
|
||||
if (!d.has("type") || String(d["type"]) != "export_patch") {
|
||||
return false;
|
||||
}
|
||||
|
||||
patches->set_drop_mode_flags(Tree::DROP_MODE_ON_ITEM);
|
||||
|
||||
@@ -679,12 +702,13 @@ void ProjectExportDialog::drop_data_fw(const Point2 &p_point, const Variant &p_d
|
||||
to_pos = presets->get_item_at_position(p_point, true);
|
||||
}
|
||||
|
||||
if (to_pos == -1 && !presets->is_pos_at_end_of_items(p_point))
|
||||
if (to_pos == -1 && !presets->is_pos_at_end_of_items(p_point)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (to_pos == from_pos)
|
||||
if (to_pos == from_pos) {
|
||||
return;
|
||||
else if (to_pos > from_pos) {
|
||||
} else if (to_pos > from_pos) {
|
||||
to_pos--;
|
||||
}
|
||||
|
||||
@@ -693,26 +717,29 @@ void ProjectExportDialog::drop_data_fw(const Point2 &p_point, const Variant &p_d
|
||||
EditorExport::get_singleton()->add_export_preset(preset, to_pos);
|
||||
|
||||
_update_presets();
|
||||
if (to_pos >= 0)
|
||||
if (to_pos >= 0) {
|
||||
_edit_preset(to_pos);
|
||||
else
|
||||
} else {
|
||||
_edit_preset(presets->get_item_count() - 1);
|
||||
}
|
||||
} else if (p_from == patches) {
|
||||
Dictionary d = p_data;
|
||||
if (!d.has("type") || String(d["type"]) != "export_patch")
|
||||
if (!d.has("type") || String(d["type"]) != "export_patch") {
|
||||
return;
|
||||
}
|
||||
|
||||
int from_pos = d["patch"];
|
||||
|
||||
TreeItem *item = patches->get_item_at_position(p_point);
|
||||
if (!item)
|
||||
if (!item) {
|
||||
return;
|
||||
}
|
||||
|
||||
int to_pos = item->get_cell_mode(0) == TreeItem::CELL_MODE_CHECK ? int(item->get_metadata(0)) : -1;
|
||||
|
||||
if (to_pos == from_pos)
|
||||
if (to_pos == from_pos) {
|
||||
return;
|
||||
else if (to_pos > from_pos) {
|
||||
} else if (to_pos > from_pos) {
|
||||
to_pos--;
|
||||
}
|
||||
|
||||
@@ -726,12 +753,14 @@ void ProjectExportDialog::drop_data_fw(const Point2 &p_point, const Variant &p_d
|
||||
}
|
||||
|
||||
void ProjectExportDialog::_export_type_changed(int p_which) {
|
||||
if (updating)
|
||||
if (updating) {
|
||||
return;
|
||||
}
|
||||
|
||||
Ref<EditorExportPreset> current = get_current_preset();
|
||||
if (current.is_null())
|
||||
if (current.is_null()) {
|
||||
return;
|
||||
}
|
||||
|
||||
current->set_export_filter(EditorExportPreset::ExportFilter(p_which));
|
||||
updating = true;
|
||||
@@ -740,12 +769,14 @@ void ProjectExportDialog::_export_type_changed(int p_which) {
|
||||
}
|
||||
|
||||
void ProjectExportDialog::_filter_changed(const String &p_filter) {
|
||||
if (updating)
|
||||
if (updating) {
|
||||
return;
|
||||
}
|
||||
|
||||
Ref<EditorExportPreset> current = get_current_preset();
|
||||
if (current.is_null())
|
||||
if (current.is_null()) {
|
||||
return;
|
||||
}
|
||||
|
||||
current->set_include_filter(include_filters->get_text());
|
||||
current->set_exclude_filter(exclude_filters->get_text());
|
||||
@@ -757,8 +788,9 @@ void ProjectExportDialog::_fill_resource_tree() {
|
||||
include_margin->hide();
|
||||
|
||||
Ref<EditorExportPreset> current = get_current_preset();
|
||||
if (current.is_null())
|
||||
if (current.is_null()) {
|
||||
return;
|
||||
}
|
||||
|
||||
EditorExportPreset::ExportFilter f = current->get_export_filter();
|
||||
|
||||
@@ -790,8 +822,9 @@ bool ProjectExportDialog::_fill_tree(EditorFileSystemDirectory *p_dir, TreeItem
|
||||
|
||||
for (int i = 0; i < p_dir->get_file_count(); i++) {
|
||||
String type = p_dir->get_file_type(i);
|
||||
if (p_only_scenes && type != "PackedScene")
|
||||
if (p_only_scenes && type != "PackedScene") {
|
||||
continue;
|
||||
}
|
||||
|
||||
TreeItem *file = include_files->create_item(p_item);
|
||||
file->set_cell_mode(0, TreeItem::CELL_MODE_CHECK);
|
||||
@@ -811,16 +844,19 @@ bool ProjectExportDialog::_fill_tree(EditorFileSystemDirectory *p_dir, TreeItem
|
||||
}
|
||||
|
||||
void ProjectExportDialog::_tree_changed() {
|
||||
if (updating)
|
||||
if (updating) {
|
||||
return;
|
||||
}
|
||||
|
||||
Ref<EditorExportPreset> current = get_current_preset();
|
||||
if (current.is_null())
|
||||
if (current.is_null()) {
|
||||
return;
|
||||
}
|
||||
|
||||
TreeItem *item = include_files->get_edited();
|
||||
if (!item)
|
||||
if (!item) {
|
||||
return;
|
||||
}
|
||||
|
||||
String path = item->get_metadata(0);
|
||||
bool added = item->is_checked(0);
|
||||
@@ -859,10 +895,12 @@ void ProjectExportDialog::_validate_export_path(const String &p_path) {
|
||||
bool invalid_path = (p_path.get_file().get_basename() == "");
|
||||
|
||||
// Check if state change before needlessly messing with signals
|
||||
if (invalid_path && export_project->get_ok()->is_disabled())
|
||||
if (invalid_path && export_project->get_ok()->is_disabled()) {
|
||||
return;
|
||||
if (!invalid_path && !export_project->get_ok()->is_disabled())
|
||||
}
|
||||
if (!invalid_path && !export_project->get_ok()->is_disabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (invalid_path) {
|
||||
export_project->get_ok()->set_disabled(true);
|
||||
|
||||
Reference in New Issue
Block a user