From 3c154eb93b3a098354bf6d18a9428826ec193f90 Mon Sep 17 00:00:00 2001 From: qarmin Date: Mon, 1 Jul 2019 12:59:42 +0200 Subject: Remove unnecessary code and add some error explanations --- editor/animation_bezier_editor.cpp | 4 ++-- editor/animation_track_editor_plugins.cpp | 2 +- editor/create_dialog.cpp | 3 ++- editor/editor_plugin.cpp | 2 +- editor/groups_editor.cpp | 2 +- editor/plugins/collision_shape_2d_editor_plugin.h | 2 +- editor/plugins/curve_editor_plugin.cpp | 2 +- editor/plugins/path_2d_editor_plugin.h | 2 +- editor/plugins/script_editor_plugin.cpp | 2 +- editor/plugins/texture_region_editor_plugin.cpp | 7 ++++++- editor/project_settings_editor.cpp | 4 ++-- editor/scene_tree_dock.cpp | 1 - editor/spatial_editor_gizmos.cpp | 4 ++-- 13 files changed, 21 insertions(+), 16 deletions(-) (limited to 'editor') diff --git a/editor/animation_bezier_editor.cpp b/editor/animation_bezier_editor.cpp index e524dffd43..14ea18f885 100644 --- a/editor/animation_bezier_editor.cpp +++ b/editor/animation_bezier_editor.cpp @@ -275,8 +275,6 @@ void AnimationBezierTrackEdit::_notification(int p_what) { int margin = 0; { - int ofs = 0; - NodePath path = animation->track_get_path(track); Node *node = NULL; @@ -290,6 +288,8 @@ void AnimationBezierTrackEdit::_notification(int p_what) { int h = font->get_height(); if (node) { + int ofs = 0; + Ref icon = EditorNode::get_singleton()->get_object_icon(node, "Node"); h = MAX(h, icon->get_height()); diff --git a/editor/animation_track_editor_plugins.cpp b/editor/animation_track_editor_plugins.cpp index 07dbc1fd81..226eef9c1e 100644 --- a/editor/animation_track_editor_plugins.cpp +++ b/editor/animation_track_editor_plugins.cpp @@ -1009,7 +1009,7 @@ void AnimationTrackEditTypeAudio::drop_data(const Point2 &p_point, const Variant } } - return AnimationTrackEdit::drop_data(p_point, p_data); + AnimationTrackEdit::drop_data(p_point, p_data); } void AnimationTrackEditTypeAudio::_gui_input(const Ref &p_event) { diff --git a/editor/create_dialog.cpp b/editor/create_dialog.cpp index e84602b29f..c79f7c7484 100644 --- a/editor/create_dialog.cpp +++ b/editor/create_dialog.cpp @@ -308,8 +308,9 @@ void CreateDialog::_update_search() { if (cpp_type && !ClassDB::can_instance(type)) continue; // can't create what can't be instanced - bool skip = false; if (cpp_type) { + bool skip = false; + for (Set::Element *E = type_blacklist.front(); E && !skip; E = E->next()) { if (ClassDB::is_parent_class(type, E->get())) skip = true; diff --git a/editor/editor_plugin.cpp b/editor/editor_plugin.cpp index 78c38af555..90d6c3a983 100644 --- a/editor/editor_plugin.cpp +++ b/editor/editor_plugin.cpp @@ -200,7 +200,7 @@ ScriptEditor *EditorInterface::get_script_editor() { } void EditorInterface::select_file(const String &p_file) { - return EditorNode::get_singleton()->get_filesystem_dock()->select_file(p_file); + EditorNode::get_singleton()->get_filesystem_dock()->select_file(p_file); } String EditorInterface::get_selected_path() const { diff --git a/editor/groups_editor.cpp b/editor/groups_editor.cpp index 3cf3bbf0f2..51908c65a4 100644 --- a/editor/groups_editor.cpp +++ b/editor/groups_editor.cpp @@ -69,7 +69,7 @@ void GroupDialog::_load_nodes(Node *p_current) { keep = false; } - TreeItem *node; + TreeItem *node = NULL; NodePath path = scene_tree->get_edited_scene_root()->get_path_to(p_current); if (keep && p_current->is_in_group(selected_group)) { if (remove_filter->get_text().is_subsequence_ofi(String(p_current->get_name()))) { diff --git a/editor/plugins/collision_shape_2d_editor_plugin.h b/editor/plugins/collision_shape_2d_editor_plugin.h index 965e6c8827..10a1a6bd98 100644 --- a/editor/plugins/collision_shape_2d_editor_plugin.h +++ b/editor/plugins/collision_shape_2d_editor_plugin.h @@ -89,7 +89,7 @@ class CollisionShape2DEditorPlugin : public EditorPlugin { public: virtual bool forward_canvas_gui_input(const Ref &p_event) { return collision_shape_2d_editor->forward_canvas_gui_input(p_event); } - virtual void forward_canvas_draw_over_viewport(Control *p_overlay) { return collision_shape_2d_editor->forward_canvas_draw_over_viewport(p_overlay); } + virtual void forward_canvas_draw_over_viewport(Control *p_overlay) { collision_shape_2d_editor->forward_canvas_draw_over_viewport(p_overlay); } virtual String get_name() const { return "CollisionShape2D"; } bool has_main_screen() const { return false; } diff --git a/editor/plugins/curve_editor_plugin.cpp b/editor/plugins/curve_editor_plugin.cpp index 3b1d728b8b..d2d2b8f130 100644 --- a/editor/plugins/curve_editor_plugin.cpp +++ b/editor/plugins/curve_editor_plugin.cpp @@ -156,9 +156,9 @@ void CurveEditor::on_gui_input(const Ref &p_event) { Vector2 mpos = mm.get_position(); if (_dragging && _curve_ref.is_valid()) { - Curve &curve = **_curve_ref; if (_selected_point != -1) { + Curve &curve = **_curve_ref; if (!_has_undo_data) { // Save full curve state before dragging points, diff --git a/editor/plugins/path_2d_editor_plugin.h b/editor/plugins/path_2d_editor_plugin.h index 4edd17d146..44472f7a81 100644 --- a/editor/plugins/path_2d_editor_plugin.h +++ b/editor/plugins/path_2d_editor_plugin.h @@ -123,7 +123,7 @@ class Path2DEditorPlugin : public EditorPlugin { public: virtual bool forward_canvas_gui_input(const Ref &p_event) { return path2d_editor->forward_gui_input(p_event); } - virtual void forward_canvas_draw_over_viewport(Control *p_overlay) { return path2d_editor->forward_canvas_draw_over_viewport(p_overlay); } + virtual void forward_canvas_draw_over_viewport(Control *p_overlay) { path2d_editor->forward_canvas_draw_over_viewport(p_overlay); } virtual String get_name() const { return "Path2D"; } bool has_main_screen() const { return false; } diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp index 1b00889e9a..d999f3189e 100644 --- a/editor/plugins/script_editor_plugin.cpp +++ b/editor/plugins/script_editor_plugin.cpp @@ -3463,7 +3463,7 @@ void ScriptEditorPlugin::get_window_layout(Ref p_layout) { void ScriptEditorPlugin::get_breakpoints(List *p_breakpoints) { - return script_editor->get_breakpoints(p_breakpoints); + script_editor->get_breakpoints(p_breakpoints); } void ScriptEditorPlugin::edited_scene_changed() { diff --git a/editor/plugins/texture_region_editor_plugin.cpp b/editor/plugins/texture_region_editor_plugin.cpp index 4e15bd5116..8f58fbd6ab 100644 --- a/editor/plugins/texture_region_editor_plugin.cpp +++ b/editor/plugins/texture_region_editor_plugin.cpp @@ -192,8 +192,8 @@ void TextureRegionEditor::_region_draw() { } updating_scroll = false; - float margins[4]; if (node_ninepatch || obj_styleBox.is_valid()) { + float margins[4]; if (node_ninepatch) { margins[0] = node_ninepatch->get_patch_margin(MARGIN_TOP); margins[1] = node_ninepatch->get_patch_margin(MARGIN_BOTTOM); @@ -204,6 +204,11 @@ void TextureRegionEditor::_region_draw() { margins[1] = obj_styleBox->get_margin_size(MARGIN_BOTTOM); margins[2] = obj_styleBox->get_margin_size(MARGIN_LEFT); margins[3] = obj_styleBox->get_margin_size(MARGIN_RIGHT); + } else { + margins[0] = 0; + margins[1] = 0; + margins[2] = 0; + margins[3] = 0; } Vector2 pos[4] = { mtx.basis_xform(Vector2(0, margins[0])) + Vector2(0, endpoints[0].y - draw_ofs.y * draw_zoom), diff --git a/editor/project_settings_editor.cpp b/editor/project_settings_editor.cpp index df0dd8781e..4dc40a850f 100644 --- a/editor/project_settings_editor.cpp +++ b/editor/project_settings_editor.cpp @@ -257,7 +257,7 @@ void ProjectSettingsEditor::_device_input_add() { Ref jm; jm.instance(); jm->set_axis(device_index->get_selected() >> 1); - jm->set_axis_value(device_index->get_selected() & 1 ? 1 : -1); + jm->set_axis_value((device_index->get_selected() & 1) ? 1 : -1); jm->set_device(_get_current_device()); for (int i = 0; i < events.size(); i++) { @@ -483,7 +483,7 @@ void ProjectSettingsEditor::_add_item(int p_item, Ref p_exiting_even for (int i = 0; i < JOY_AXIS_MAX * 2; i++) { String desc = _axis_names[i]; - device_index->add_item(TTR("Axis") + " " + itos(i / 2) + " " + (i & 1 ? "+" : "-") + desc); + device_index->add_item(TTR("Axis") + " " + itos(i / 2) + " " + ((i & 1) ? "+" : "-") + desc); } device_input->popup_centered_minsize(Size2(350, 95) * EDSCALE); diff --git a/editor/scene_tree_dock.cpp b/editor/scene_tree_dock.cpp index a15ae2efda..e5ce834d79 100644 --- a/editor/scene_tree_dock.cpp +++ b/editor/scene_tree_dock.cpp @@ -1493,7 +1493,6 @@ void SceneTreeDock::_do_reparent(Node *p_new_parent, int p_position_in_parent, V if (p_nodes.find(validate) != -1) { ERR_EXPLAIN("Selection changed at some point.. can't reparent"); ERR_FAIL(); - return; } validate = validate->get_parent(); } diff --git a/editor/spatial_editor_gizmos.cpp b/editor/spatial_editor_gizmos.cpp index fc4ff2ecfc..fe6d9dd8c7 100644 --- a/editor/spatial_editor_gizmos.cpp +++ b/editor/spatial_editor_gizmos.cpp @@ -147,7 +147,7 @@ void EditorSpatialGizmo::set_handle(int p_idx, Camera *p_camera, const Point2 &p } ERR_FAIL_COND(!gizmo_plugin); - return gizmo_plugin->set_handle(this, p_idx, p_camera, p_point); + gizmo_plugin->set_handle(this, p_idx, p_camera, p_point); } void EditorSpatialGizmo::commit_handle(int p_idx, const Variant &p_restore, bool p_cancel) { @@ -158,7 +158,7 @@ void EditorSpatialGizmo::commit_handle(int p_idx, const Variant &p_restore, bool } ERR_FAIL_COND(!gizmo_plugin); - return gizmo_plugin->commit_handle(this, p_idx, p_restore, p_cancel); + gizmo_plugin->commit_handle(this, p_idx, p_restore, p_cancel); } void EditorSpatialGizmo::set_spatial_node(Spatial *p_node) { -- cgit v1.2.3