summaryrefslogtreecommitdiff
path: root/editor/plugins
diff options
context:
space:
mode:
authorHein-Pieter van Braam <hp@tmm.cx>2017-09-06 23:50:18 +0200
committerHein-Pieter van Braam <hp@tmm.cx>2017-09-08 14:59:15 +0200
commit8230bf0a2f39f0849b670d26067207c45edcca1a (patch)
tree42f598d11fab7f1449d0cace0f991f546bd72e72 /editor/plugins
parentd1cb73b47a17de830d9474026ffa7b3587cfbc68 (diff)
Remove assignment and declarations in if statements
After discussing with @reduz and @akien-mga it was decided that we do not allow assignments or declarations in if statements. This PR removes the instances of this I could find by automated means.
Diffstat (limited to 'editor/plugins')
-rw-r--r--editor/plugins/canvas_item_editor_plugin.cpp17
1 files changed, 10 insertions, 7 deletions
diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp
index 3d5732c749..f7c56bdc2e 100644
--- a/editor/plugins/canvas_item_editor_plugin.cpp
+++ b/editor/plugins/canvas_item_editor_plugin.cpp
@@ -580,7 +580,8 @@ void CanvasItemEditor::_key_move(const Vector2 &p_dir, bool p_snap, KeyMoveMODE
} else { // p_move_mode==MOVE_LOCAL_BASE || p_move_mode==MOVE_LOCAL_WITH_ROT
- if (Node2D *node_2d = Object::cast_to<Node2D>(canvas_item)) {
+ Node2D *node_2d = Object::cast_to<Node2D>(canvas_item);
+ if (node_2d) {
if (p_move_mode == MOVE_LOCAL_WITH_ROT) {
Transform2D m;
@@ -589,9 +590,10 @@ void CanvasItemEditor::_key_move(const Vector2 &p_dir, bool p_snap, KeyMoveMODE
}
node_2d->set_position(node_2d->get_position() + drag);
- } else if (Control *control = Object::cast_to<Control>(canvas_item)) {
-
- control->set_position(control->get_position() + drag);
+ } else {
+ Control *control = Object::cast_to<Control>(canvas_item);
+ if (control)
+ control->set_position(control->get_position() + drag);
}
}
}
@@ -742,7 +744,8 @@ float CanvasItemEditor::_anchor_snap(float p_anchor, bool *p_snapped, float p_op
float radius = 0.05 / zoom;
float basic_anchors[3] = { 0.0, 0.5, 1.0 };
for (int i = 0; i < 3; i++) {
- if ((dist = fabs(p_anchor - basic_anchors[i])) < radius) {
+ dist = fabs(p_anchor - basic_anchors[i]);
+ if (dist < radius) {
if (!snapped || dist <= dist_min) {
p_anchor = basic_anchors[i];
dist_min = dist;
@@ -750,7 +753,8 @@ float CanvasItemEditor::_anchor_snap(float p_anchor, bool *p_snapped, float p_op
}
}
}
- if (p_opposite_anchor >= 0 && (dist = fabs(p_anchor - p_opposite_anchor)) < radius) {
+ dist = fabs(p_anchor - p_opposite_anchor);
+ if (p_opposite_anchor >= 0 && dist < radius) {
if (!snapped || dist <= dist_min) {
p_anchor = p_opposite_anchor;
dist_min = dist;
@@ -2269,7 +2273,6 @@ void CanvasItemEditor::_notification(int p_what) {
if (p_what == NOTIFICATION_FIXED_PROCESS) {
-
EditorNode::get_singleton()->get_scene_root()->set_snap_controls_to_pixels(GLOBAL_GET("gui/common/snap_controls_to_pixels"));
List<Node *> &selection = editor_selection->get_selected_node_list();