Properly handle node remove via undo

This commit is contained in:
Tomasz Chabora
2020-03-29 19:59:04 +02:00
parent fafb0ba06d
commit 37ffb40047
4 changed files with 36 additions and 0 deletions

View File

@@ -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) {