diff options
Diffstat (limited to 'editor')
-rw-r--r-- | editor/import/resource_importer_scene.cpp | 4 | ||||
-rw-r--r-- | editor/plugins/canvas_item_editor_plugin.cpp | 17 | ||||
-rw-r--r-- | editor/scene_tree_dock.cpp | 45 |
3 files changed, 40 insertions, 26 deletions
diff --git a/editor/import/resource_importer_scene.cpp b/editor/import/resource_importer_scene.cpp index 594728d2e0..e78d083a56 100644 --- a/editor/import/resource_importer_scene.cpp +++ b/editor/import/resource_importer_scene.cpp @@ -230,8 +230,8 @@ Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Array if (isroot) return p_node; - - if (MeshInstance *mi = Object::cast_to<MeshInstance>(p_node)) { + MeshInstance *mi = Object::cast_to<MeshInstance>(p_node); + if (mi) { Node *col = mi->create_trimesh_collision_node(); ERR_FAIL_COND_V(!col, NULL); 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(); diff --git a/editor/scene_tree_dock.cpp b/editor/scene_tree_dock.cpp index afdf48b314..232b5e980a 100644 --- a/editor/scene_tree_dock.cpp +++ b/editor/scene_tree_dock.cpp @@ -582,13 +582,13 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { new_scene_from_dialog->popup_centered_ratio(); new_scene_from_dialog->set_title(TTR("Save New Scene As..")); - } break; case TOOL_COPY_NODE_PATH: { List<Node *> selection = editor_selection->get_selected_node_list(); - - if (List<Node *>::Element *e = selection.front()) { - if (Node *node = e->get()) { + List<Node *>::Element *e = selection.front(); + if (e) { + Node *node = e->get(); + if (node) { Node *root = EditorNode::get_singleton()->get_edited_scene(); NodePath path = root->get_path().rel_path_to(node->get_path()); OS::get_singleton()->set_clipboard(path); @@ -597,8 +597,10 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { } break; case TOOL_SCENE_EDITABLE_CHILDREN: { List<Node *> selection = editor_selection->get_selected_node_list(); - if (List<Node *>::Element *e = selection.front()) { - if (Node *node = e->get()) { + List<Node *>::Element *e = selection.front(); + if (e) { + Node *node = e->get(); + if (node) { bool editable = EditorNode::get_singleton()->get_edited_scene()->is_editable_instance(node); int editable_item_idx = menu->get_item_idx_from_text(TTR("Editable Children")); int placeholder_item_idx = menu->get_item_idx_from_text(TTR("Load As Placeholder")); @@ -617,8 +619,10 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { } break; case TOOL_SCENE_USE_PLACEHOLDER: { List<Node *> selection = editor_selection->get_selected_node_list(); - if (List<Node *>::Element *e = selection.front()) { - if (Node *node = e->get()) { + List<Node *>::Element *e = selection.front(); + if (e) { + Node *node = e->get(); + if (node) { bool placeholder = node->get_scene_instance_load_placeholder(); placeholder = !placeholder; int editable_item_idx = menu->get_item_idx_from_text(TTR("Editable Children")); @@ -635,15 +639,16 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { } break; case TOOL_SCENE_CLEAR_INSTANCING: { List<Node *> selection = editor_selection->get_selected_node_list(); - if (List<Node *>::Element *e = selection.front()) { - if (Node *node = e->get()) { + List<Node *>::Element *e = selection.front(); + if (e) { + Node *node = e->get(); + if (node) { Node *root = EditorNode::get_singleton()->get_edited_scene(); UndoRedo *undo_redo = &editor_data->get_undo_redo(); if (!root) break; ERR_FAIL_COND(node->get_filename() == String()); - undo_redo->create_action(TTR("Discard Instancing")); undo_redo->add_do_method(node, "set_filename", ""); undo_redo->add_undo_method(node, "set_filename", node->get_filename()); @@ -656,8 +661,10 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { } break; case TOOL_SCENE_OPEN: { List<Node *> selection = editor_selection->get_selected_node_list(); - if (List<Node *>::Element *e = selection.front()) { - if (Node *node = e->get()) { + List<Node *>::Element *e = selection.front(); + if (e) { + Node *node = e->get(); + if (node) { scene_tree->emit_signal("open", node->get_filename()); } } @@ -667,8 +674,10 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { } break; case TOOL_SCENE_CLEAR_INHERITANCE_CONFIRM: { List<Node *> selection = editor_selection->get_selected_node_list(); - if (List<Node *>::Element *e = selection.front()) { - if (Node *node = e->get()) { + List<Node *>::Element *e = selection.front(); + if (e) { + Node *node = e->get(); + if (node) { node->set_scene_inherited_state(Ref<SceneState>()); scene_tree->update_tree(); EditorNode::get_singleton()->get_property_editor()->update_tree(); @@ -677,8 +686,10 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { } break; case TOOL_SCENE_OPEN_INHERITED: { List<Node *> selection = editor_selection->get_selected_node_list(); - if (List<Node *>::Element *e = selection.front()) { - if (Node *node = e->get()) { + List<Node *>::Element *e = selection.front(); + if (e) { + Node *node = e->get(); + if (node) { if (node && node->get_scene_inherited_state().is_valid()) { scene_tree->emit_signal("open", node->get_scene_inherited_state()->get_path()); } |