diff options
author | Tomasz Chabora <kobewi4e@gmail.com> | 2020-03-29 19:59:04 +0200 |
---|---|---|
committer | Tomasz Chabora <kobewi4e@gmail.com> | 2020-03-29 19:59:04 +0200 |
commit | 37ffb4004750314f5222e4b27b4deee619c6344f (patch) | |
tree | 3937ecc447630966680d5629714d3f44ae2ef84a /editor/plugins/collision_shape_2d_editor_plugin.cpp | |
parent | fafb0ba06df9417a22bd8deb31a61feeb24de794 (diff) | |
download | redot-engine-37ffb4004750314f5222e4b27b4deee619c6344f.tar.gz |
Properly handle node remove via undo
Diffstat (limited to 'editor/plugins/collision_shape_2d_editor_plugin.cpp')
-rw-r--r-- | editor/plugins/collision_shape_2d_editor_plugin.cpp | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/editor/plugins/collision_shape_2d_editor_plugin.cpp b/editor/plugins/collision_shape_2d_editor_plugin.cpp index 709ff91fc0..2d1d6de574 100644 --- a/editor/plugins/collision_shape_2d_editor_plugin.cpp +++ b/editor/plugins/collision_shape_2d_editor_plugin.cpp @@ -39,6 +39,13 @@ #include "scene/resources/rectangle_shape_2d.h" #include "scene/resources/segment_shape_2d.h" +void CollisionShape2DEditor::_node_removed(Node *p_node) { + + if (p_node == node) { + node = NULL; + } +} + Variant CollisionShape2DEditor::get_handle_value(int idx) const { switch (shape_type) { @@ -525,6 +532,20 @@ void CollisionShape2DEditor::forward_canvas_draw_over_viewport(Control *p_overla } } +void CollisionShape2DEditor::_notification(int p_what) { + + switch (p_what) { + + case NOTIFICATION_ENTER_TREE: { + get_tree()->connect("node_removed", callable_mp(this, &CollisionShape2DEditor::_node_removed)); + } break; + + case NOTIFICATION_EXIT_TREE: { + get_tree()->disconnect("node_removed", callable_mp(this, &CollisionShape2DEditor::_node_removed)); + } break; + } +} + void CollisionShape2DEditor::edit(Node *p_node) { if (!canvas_item_editor) { |