godotengine / godotengine/godot
TileSet: Leftover patterns after TileSet atlas source removal causes output error spam "No TileSet atlas source with id N"
- Dominant language
- C++
- Stars
- 117k
- Forks
- 26.8k
- PR merge metrics
- PR metrics pending
Description
### Tested versions
- Reproducible in: v4.2.1.stable.official [b09f793f5]
### System information
Godot v4.2.1.stable - Ubuntu 22.04.4 LTS 22.04 - X11 - Vulkan (Mobile) - dedicated NVIDIA GeForce GTX 860M (nvidia; 535.161.07) - Intel(R) Core(TM) i7-4710HQ CPU @ 2.50GHz (8 Threads)
### Issue description
After creating TileSet patterns using some tiles from a given atlas source (Atlas or Scene Collection):

and deleting that atlas source, all patterns using that source will be replaced with "ghost" patterns (show nothing but still selectable):

(note: the middle pattern is never visible because it uses a scene collection, which doesn't seem to support preview - it is not what this bug is about - it's easier to see the bug with Atlas tiles)
and each time user opens the TileMap panel and Output error will appear:
> No TileSet atlas source with id 1.
(or 2, etc. depending on the ID of the removed TileSets that were used in patterns)
with one error message per pattern using a removed atlas source.
Note that if you also used said tiles/scenes in the actual tilemap, these asserts may also trigger:
> editor/plugins/tiles/tile_set_atlas_source_editor.cpp:130 - Condition "p_tile_set.is_valid() && p_tile_set->get_source(p_source_id) != p_tile_set_atlas_source" is true.
editor/plugins/tiles/tile_atlas_view.cpp:446 - Condition "p_tile_set->get_source(p_source_id) != p_tile_set_atlas_source" is true.

but they are a different issue. This issue is only about leftover **patterns** using removed tiles/scenes.
The error is even more problematic as there is no explanation of the cause of the issue in the error message. I had to inspect the TileSet tres to spot the existence of ghost patterns.
Opening the Patterns tab, user can indeed highlight empty rectangles where the patterns originally were, and delete them to fix the issue.

I suggest giving a clearer error message such as "TileSet pattern number M uses TileSet atlas source number ID N, but it is missing (must have been removed). Consider restoring the TileSet ID N, or deleting the pattern number M."
In addition, missing atlas tiles/scenes could be represented with a striped square with a warning sign, similarly to how missing tiles/scenes are shown on the TileMap after removing a TileSet atlas source.

Since the error is technically correct and I'm asking for more clarity, this could also be turned into a feature proposal if you prefer.
### Steps to reproduce
1. Open the sample project
2. Open demo.tscn
3. Select TileMap After Removal node and open the TileMap tab (should be automatic)
4. Check the output for errors:
> No TileSet atlas source with id 0.
No TileSet atlas source with id 1.
5. Now let's reproduce this. First, clear the output log to show we are really reproducing new errors.
6. Select TileMap Before Removal node > TileMap tab (this time, no errors)
7. Switch to Patterns tab > note there are 3 entries. The middle one contains a Scene from a Scene Collection and is not previewable so it looks empty, but it is valid at this point
8. Go back to Tiles tab to see Atlas sources
9. Remove one or two sources (the most obvious is to remove "icon.svg" which is an Atlas with previewable patterns, but you can also remove the Scene Collection Source) => note the red dot that shows Output errors
10. Switch back to Patterns tab to verify that patterns are now all invisible
Steps 8-9-10:
[Godot 4.2.1 - removing atlas source leaves leftover patterns.webm](https://github.com/godotengine/godot/assets/1067772/fa5d5ab5-9329-4d23-8c3a-f3b4ca046b7b)
11. Check the Output log for errors
### Minimal reproduction project (MRP)
[Godot 4.2.1 - TileSet remove first one cause ERROR: No TileSet atlas source with id 1.zip](https://github.com/godotengine/godot/files/14764216/Godot.4.2.1.-.TileSet.remove.first.one.cause.ERROR.No.TileSet.atlas.source.with.id.1.zip)
Contributor guide
Research direction
Reproduce the issue with the attached minimal reproduction project by removing an atlas source, then inspect the TileMap Patterns tab and Output panel. Trace the handling of patterns that reference removed sources, keeping the separate assertions in editor/plugins/tiles/tile_set_atlas_source_editor.cpp and tile_atlas_view.cpp out of scope. Done means removed-source patterns no longer produce unexplained errors and their remaining state is clearly handled.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- game-dev, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100