Skip to content

Commit

Permalink
Check before connecting TileMapEditor::settings_changed
Browse files Browse the repository at this point in the history
  • Loading branch information
Chaosus committed Mar 1, 2021
1 parent 165d77a commit 1e7662f
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions editor/plugins/tile_map_editor_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,12 @@

void TileMapEditor::_node_removed(Node *p_node) {
if (p_node == node && node) {
// Fixes #44824, which describes a situation where you can reselect a TileMap node without first de-selecting it when switching scenes.
node->disconnect("settings_changed", callable_mp(this, &TileMapEditor::_tileset_settings_changed));
Callable callable_tileset_settings_changed = callable_mp(this, &TileMapEditor::_tileset_settings_changed);

if (node->is_connected("settings_changed", callable_tileset_settings_changed)) {
// Fixes #44824, which describes a situation where you can reselect a TileMap node without first de-selecting it when switching scenes.
node->disconnect("settings_changed", callable_tileset_settings_changed);
}
node = nullptr;
}
}
Expand Down Expand Up @@ -1870,7 +1873,11 @@ void TileMapEditor::edit(Node *p_tile_map) {
}

if (node) {
node->disconnect("settings_changed", callable_mp(this, &TileMapEditor::_tileset_settings_changed));
Callable callable_tileset_settings_changed = callable_mp(this, &TileMapEditor::_tileset_settings_changed);

if (node->is_connected("settings_changed", callable_tileset_settings_changed)) {
node->disconnect("settings_changed", callable_tileset_settings_changed);
}
}
if (p_tile_map) {
node = Object::cast_to<TileMap>(p_tile_map);
Expand All @@ -1897,7 +1904,11 @@ void TileMapEditor::edit(Node *p_tile_map) {
}

if (node) {
node->connect("settings_changed", callable_mp(this, &TileMapEditor::_tileset_settings_changed));
Callable callable_tileset_settings_changed = callable_mp(this, &TileMapEditor::_tileset_settings_changed);

if (!node->is_connected("settings_changed", callable_tileset_settings_changed)) {
node->connect("settings_changed", callable_tileset_settings_changed);
}
}

_clear_bucket_cache();
Expand Down

0 comments on commit 1e7662f

Please sign in to comment.