godotengine / godotengine/godot

Adding a TileMapPattern via code to a TileMap and saving it to disk crashes the editor

Open
#95,043 4 comments 1 reaction 0 assignees View on GitHub
bug confirmed crash topic:2d topic:editor
Dominant language
C++
Stars
117k
Forks
26.8k
PR merge metrics
PR metrics pending

Description

### Tested versions

Reproducible on v4.3.rc1.official [e343dbbcc] and v4.2.2.stable.official [15073afe3]

### System information

Godot v4.3.rc1 - Windows 10.0.22631 - Vulkan (Forward+) - dedicated Radeon (TM) RX 480 Graphics (Advanced Micro Devices, Inc.; 31.0.12042.4) - AMD Ryzen 7 5700G with Radeon Graphics (16 Threads)

### Issue description

I'm trying to add a TileMapPattern via code.
I may be using the resource incorrectly, but since the editor crashes without any error messages, i'm not sure what is wrong.

Via code, I'm creating a TileSetAtlasSource, TileSet, TileMapPattern and TileMap (or TileMapLayer). The crash only happens if I run the function TileMapPattern.set_cell().
Adding an empty pattern does not cause a crash.

### Steps to reproduce

```
var img := Image.create(1000,1000,false, Image.FORMAT_RGB8)
var tex := ImageTexture.create_from_image(img)

var atlas_tile := TileSetAtlasSource.new()
atlas_tile.texture = tex

var tileset := TileSet.new()
tileset.add_source(atlas_tile)

#var tml := TileMapLayer.new() # Tilemaplayer
var tml := TileMap.new() # Tilemap
tml.tile_set = tileset

var pattern := TileMapPattern.new()
pattern.set_cell( Vector2i(25,25) ) # Disabling this does not cause a crash
pattern.set_size( Vector2i(50,50) )

tileset.add_pattern( pattern ) # Disabling this does not cause a crash

var scene = PackedScene.new()
scene.pack( tml )
ResourceSaver.save(scene, "res://tilemaplayer.tscn")
```

### Minimal reproduction project (MRP)

[crash.zip](https://github.com/user-attachments/files/16462710/crash.zip)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.