summaryrefslogtreecommitdiff
path: root/editor/plugins/tiles
diff options
context:
space:
mode:
authorkobewi <kobewi4e@gmail.com>2023-02-14 00:39:41 +0100
committerkobewi <kobewi4e@gmail.com>2023-02-14 00:39:41 +0100
commitbe6d5bbba609e34ebde0a9cd37dc45216fa2d476 (patch)
treee459e4de074272eabad4febd152c511819a2379b /editor/plugins/tiles
parent4848877b802b17f4ab1aecfde42c81a7cc9b6f08 (diff)
Fix some TileMap errors and crashes
Diffstat (limited to 'editor/plugins/tiles')
-rw-r--r--editor/plugins/tiles/tile_atlas_view.cpp11
-rw-r--r--editor/plugins/tiles/tile_set_atlas_source_editor.cpp11
2 files changed, 16 insertions, 6 deletions
diff --git a/editor/plugins/tiles/tile_atlas_view.cpp b/editor/plugins/tiles/tile_atlas_view.cpp
index fd651dd507..43c6d1a48b 100644
--- a/editor/plugins/tiles/tile_atlas_view.cpp
+++ b/editor/plugins/tiles/tile_atlas_view.cpp
@@ -404,13 +404,16 @@ void TileAtlasView::_draw_background_right() {
}
void TileAtlasView::set_atlas_source(TileSet *p_tile_set, TileSetAtlasSource *p_tile_set_atlas_source, int p_source_id) {
- ERR_FAIL_COND(!p_tile_set);
- ERR_FAIL_COND(!p_tile_set_atlas_source);
+ tile_set = p_tile_set;
+ tile_set_atlas_source = p_tile_set_atlas_source;
+
+ if (!tile_set) {
+ return;
+ }
+
ERR_FAIL_COND(p_source_id < 0);
ERR_FAIL_COND(p_tile_set->get_source(p_source_id) != p_tile_set_atlas_source);
- tile_set = p_tile_set;
- tile_set_atlas_source = p_tile_set_atlas_source;
source_id = p_source_id;
// Show or hide the view.
diff --git a/editor/plugins/tiles/tile_set_atlas_source_editor.cpp b/editor/plugins/tiles/tile_set_atlas_source_editor.cpp
index 912fdb03a9..e56541b50d 100644
--- a/editor/plugins/tiles/tile_set_atlas_source_editor.cpp
+++ b/editor/plugins/tiles/tile_set_atlas_source_editor.cpp
@@ -120,10 +120,9 @@ void TileSetAtlasSourceEditor::TileSetAtlasSourceProxyObject::_bind_methods() {
}
void TileSetAtlasSourceEditor::TileSetAtlasSourceProxyObject::edit(Ref<TileSet> p_tile_set, TileSetAtlasSource *p_tile_set_atlas_source, int p_source_id) {
- ERR_FAIL_COND(!p_tile_set.is_valid());
ERR_FAIL_COND(!p_tile_set_atlas_source);
ERR_FAIL_COND(p_source_id < 0);
- ERR_FAIL_COND(p_tile_set->get_source(p_source_id) != p_tile_set_atlas_source);
+ ERR_FAIL_COND(p_tile_set.is_valid() && p_tile_set->get_source(p_source_id) != p_tile_set_atlas_source);
if (p_tile_set == tile_set && p_tile_set_atlas_source == tile_set_atlas_source && p_source_id == source_id) {
return;
@@ -611,6 +610,10 @@ void TileSetAtlasSourceEditor::_update_tile_data_editors() {
tile_data_editors_tree->clear();
+ if (tile_set.is_null()) {
+ return;
+ }
+
TreeItem *root = tile_data_editors_tree->create_item();
TreeItem *group;
@@ -919,6 +922,10 @@ void TileSetAtlasSourceEditor::_update_atlas_view() {
alternative_tiles_control->get_child(i)->queue_free();
}
+ if (tile_set.is_null()) {
+ return;
+ }
+
Vector2i pos;
Vector2 texture_region_base_size = tile_set_atlas_source->get_texture_region_size();
int texture_region_base_size_min = MIN(texture_region_base_size.x, texture_region_base_size.y);