You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-07 12:30:27 +00:00
Properly handle node remove via undo
(cherry picked from commit 37ffb40047)
This commit is contained in:
committed by
Rémi Verschelde
parent
3658f7127e
commit
472b0e0d34
@@ -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", this, "_node_removed");
|
||||
} break;
|
||||
|
||||
case NOTIFICATION_EXIT_TREE: {
|
||||
get_tree()->disconnect("node_removed", this, "_node_removed");
|
||||
} break;
|
||||
}
|
||||
}
|
||||
|
||||
void CollisionShape2DEditor::edit(Node *p_node) {
|
||||
|
||||
if (!canvas_item_editor) {
|
||||
@@ -549,6 +570,7 @@ void CollisionShape2DEditor::edit(Node *p_node) {
|
||||
void CollisionShape2DEditor::_bind_methods() {
|
||||
|
||||
ClassDB::bind_method("_get_current_shape_type", &CollisionShape2DEditor::_get_current_shape_type);
|
||||
ClassDB::bind_method(D_METHOD("_node_removed"), &CollisionShape2DEditor::_node_removed);
|
||||
}
|
||||
|
||||
CollisionShape2DEditor::CollisionShape2DEditor(EditorNode *p_editor) {
|
||||
|
||||
Reference in New Issue
Block a user