Merge pull request #80610 from lawnjelly/fix_tilemap_editor_plugin_crash2

Fix `TileMapEditorPlugin` crash by storing tilemap ID instead of pointer
This commit is contained in:
Rémi Verschelde 2023-08-14 15:31:19 +02:00
commit c78be12f42
No known key found for this signature in database
GPG key ID: C3336907360768E1
2 changed files with 8 additions and 1 deletions

View file

@ -325,6 +325,7 @@ void TileMapEditorPlugin::_tile_map_changed() {
}
void TileMapEditorPlugin::_update_tile_map() {
TileMap *tile_map = Object::cast_to<TileMap>(ObjectDB::get_instance(tile_map_id));
if (tile_map) {
Ref<TileSet> tile_set = tile_map->get_tileset();
if (tile_set.is_valid() && edited_tileset != tile_set->get_instance_id()) {
@ -347,11 +348,17 @@ void TileMapEditorPlugin::_notification(int p_notification) {
}
void TileMapEditorPlugin::edit(Object *p_object) {
TileMap *tile_map = Object::cast_to<TileMap>(ObjectDB::get_instance(tile_map_id));
if (tile_map) {
tile_map->disconnect("changed", callable_mp(this, &TileMapEditorPlugin::_tile_map_changed));
}
tile_map = Object::cast_to<TileMap>(p_object);
if (tile_map) {
tile_map_id = tile_map->get_instance_id();
} else {
tile_map_id = ObjectID();
}
editor->edit(tile_map);
if (tile_map) {

View file

@ -115,7 +115,7 @@ class TileMapEditorPlugin : public EditorPlugin {
TileMapEditor *editor = nullptr;
Button *button = nullptr;
TileMap *tile_map = nullptr;
ObjectID tile_map_id;
bool tile_map_changed_needs_update = false;
ObjectID edited_tileset;