summaryrefslogtreecommitdiffstats
path: root/editor/plugins/tile_map_editor_plugin.cpp
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2020-03-30 06:40:42 +0200
committerGitHub <noreply@github.com>2020-03-30 06:40:42 +0200
commit0168709978154a89f137b44f33647e5d28a46250 (patch)
tree3937ecc447630966680d5629714d3f44ae2ef84a /editor/plugins/tile_map_editor_plugin.cpp
parentfafb0ba06df9417a22bd8deb31a61feeb24de794 (diff)
parent37ffb4004750314f5222e4b27b4deee619c6344f (diff)
downloadredot-engine-0168709978154a89f137b44f33647e5d28a46250.tar.gz
Merge pull request #37412 from KoBeWi/great_tree_escape
Properly handle node remove via undo
Diffstat (limited to 'editor/plugins/tile_map_editor_plugin.cpp')
-rw-r--r--editor/plugins/tile_map_editor_plugin.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/editor/plugins/tile_map_editor_plugin.cpp b/editor/plugins/tile_map_editor_plugin.cpp
index 83dc84a0c2..6fa7955ee5 100644
--- a/editor/plugins/tile_map_editor_plugin.cpp
+++ b/editor/plugins/tile_map_editor_plugin.cpp
@@ -38,6 +38,13 @@
#include "editor/editor_settings.h"
#include "scene/gui/split_container.h"
+void TileMapEditor::_node_removed(Node *p_node) {
+
+ if (p_node == node) {
+ node = NULL;
+ }
+}
+
void TileMapEditor::_notification(int p_what) {
switch (p_what) {
@@ -60,6 +67,7 @@ void TileMapEditor::_notification(int p_what) {
case NOTIFICATION_ENTER_TREE: {
+ get_tree()->connect("node_removed", callable_mp(this, &TileMapEditor::_node_removed));
paint_button->set_icon(get_theme_icon("Edit", "EditorIcons"));
bucket_fill_button->set_icon(get_theme_icon("Bucket", "EditorIcons"));
picker_button->set_icon(get_theme_icon("ColorPick", "EditorIcons"));
@@ -80,6 +88,10 @@ void TileMapEditor::_notification(int p_what) {
p->set_item_icon(p->get_item_index(OPTION_ERASE_SELECTION), get_theme_icon("Remove", "EditorIcons"));
} break;
+
+ case NOTIFICATION_EXIT_TREE: {
+ get_tree()->disconnect("node_removed", callable_mp(this, &TileMapEditor::_node_removed));
+ } break;
}
}