godotengine / godotengine/godot
RichTextLabel (RTL): add_text(), append_text(), add_image() (and probably others) do not work on orphan RTL
- Dominant language
- C++
- Stars
- 117k
- Forks
- 26.8k
- PR merge metrics
- PR metrics pending
Description
### Tested versions
Reproducible in: v4.4.dev7.official [46c8f8c5c], v4.3.stable.official [77dcf97d8]
### System information
Godot v4.4.dev7 - Windows 11 (build 22631) - Multi-window, 1 monitor - Vulkan (Forward+) - dedicated NVIDIA GeForce MX450 (NVIDIA; 32.0.15.5613) - 11th Gen Intel(R) Core(TM) i7-1165G7 @ 2.80GHz (8 threads)
### Issue description
add_text(), append_text(), add_image() and probably other similar functions do not work on orphan RichTextLabel. Setting the text property directly works.
In the Minimal reproduction project, I only used append_text(), but in my current project in v4.3.stable.official add_image() doesn't work either.
I think it's a bug because I didn't find anything that explains why it behaves like that.
It's pretty simple to bypass putting add_child() before add_*(). Deferring the add_* functions works too. However, I think it's not the expected behavior.
### Steps to reproduce
- Create a RichTextLabel by code (instantiating a scene or creating a new RTL with enough size)
- Add some text using add_text() or append_text()
- Add the RTL to the tree with add_child()
Can be done on a brand new project. I added a Minimal reproduction project anyway.
### Minimal reproduction project (MRP)
[orphan_RTL_test.zip](https://github.com/user-attachments/files/18232032/orphan_RTL_test.zip)
Contributor guide
Research direction
Start with the attached orphan_RTL_test.zip minimal reproduction and reproduce the behavior on an orphan RichTextLabel before it is added to the tree. Compare append_text(), add_text(), and add_image() with direct text assignment; done means these methods behave as expected when called before add_child().
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, godot
- Domain
- game-dev
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100