godotengine / godotengine/godot
Using "get_theme_X" methods fail to retrieve theme property when type variation is set on Godot v4.2.x
- Dominant language
- C++
- Stars
- 117k
- Forks
- 26.8k
- PR merge metrics
- PR metrics pending
Description
### Tested versions
- Reproducible in v4.2 starting with commit [58126e479cd7341ec2ae306131e14868bcff06ca](https://github.com/godotengine/godot/commit/58126e479cd7341ec2ae306131e14868bcff06ca) @YuriSizov
- Not reproducible in v4.1.3 and versions prior to commit listed above after using git bisect
### System information
Godot v4.2.1.stable (b09f793f5) - Fedora Linux 39 (Workstation Edition) - Wayland - GLES3 (Compatibility) - AMD Radeon Graphics (radeonsi, gfx1103_r1, LLVM 17.0.6, DRM 3.54, 6.6.13-200.fc39.x86_64) () - AMD Ryzen 7 7840U w/ Radeon 780M Graphics (16 Threads)
### Issue description
Using any `get_theme_X` method (e.g. `get_theme_icon`) on a Control node with a theme variation returns an empty/invalid value. This issue goes away if you remove the theme variation property on the Control node.
For example, from the MRP, this scene has two Texture2D nodes with the same script below:
```gdscript
@tool
extends TextureRect
func _ready() -> void:
theme_changed.connect(_on_theme_changed)
_on_theme_changed()
func _on_theme_changed() -> void:
var icon := get_theme_icon("highlight", "CustomType") as Texture2D
if not icon:
return
texture = icon
```
One has its theme variation property set, while the other does not, which creates this result:

This issue does not appear in Godot v4.1.3 or versions prior to commit [58126e479cd7341ec2ae306131e14868bcff06ca](https://github.com/godotengine/godot/commit/58126e479cd7341ec2ae306131e14868bcff06ca).
### Steps to reproduce
You can run the provided MRP project to reproduce the issue.
The gist is:
- Create a theme with a custom type and theme item on that custom type
- Set the root Control node to use the theme
- Create a child Control node and set the theme variation property to use the created custom theme type
- Call any `get_theme_X` method (e.g. `get_theme_icon`) to get the theme property
### Minimal reproduction project (MRP)
[ThemeIssue-MRP.zip](https://github.com/godotengine/godot/files/14073385/ThemeIssue-MRP.zip)
Contributor guide
Research direction
Run the provided ThemeIssue-MRP.zip in Godot v4.2.x and compare a Control with a theme variation against one without it. Start by tracing theme variation resolution used by get_theme_icon and the other get_theme_X methods; done means the child Control retrieves the custom theme item instead of an empty or invalid value, while preserving the behavior reported for v4.1.3.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, godot
- Domain
- game-dev
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100