godotengine / godotengine/godot
SplitContainer.split_offsets[index] no longer updates the split position in Godot 4.7
- Dominant language
- C++
- Stars
- 117k
- Forks
- 26.8k
- PR merge metrics
- PR metrics pending
Description
### Tested versions
Reproducible in:
- v4.7.stable.official [5b4e0cb0f]
Not reproducible in:
- v4.6.2.stable.mono.official [71f334935]
Workarounds in 4.7:
- Using the deprecated split_offset property still updates the split position.
- Reassigning split_offsets to a new array also updates the split position.
### System information
Arch Linux x86_64
### Issue description
In Godot 4.7, modifying a SplitContainer's split_offsets array by index no longer updates the visible split position.
This worked in Godot 4.6:
```gd
split.split_offsets[0] = value
```
In Godot 4.7, the value doesn't appear to change in the array and the container does not visually update. The split position remains unchanged.
The old deprecated property still works:
```gd
split.split_offset = value
```
Reassigning split_offsets to a new array also works:
```gd
split.split_offsets = [value]
```
### Expected behaviour:
Modifying split_offsets[0] should update the split position, as it did in Godot 4.6.
### Actual behaviour:
Modifying split_offsets[0] does not visually update the split position in Godot 4.7. The split position only updates when using the deprecated split_offset property or when assigning a new array to split_offsets.
This appears to be a regression from Godot 4.6.
## Demo:
Below are two videos of me testing this functionality both in Godot 4.6 and 4.7:
### 4.6 (Expected):
https://github.com/user-attachments/assets/48a7ca4f-2e31-4443-90d3-a09dd3670a5a
### 4.7 (Regressed):
https://github.com/user-attachments/assets/918f593a-5201-4d89-a828-541af97af246
### Steps to reproduce
This script initialises a godot scene with a split container and then tests the split offset method, by running on both a version of 4.6 and 4.7, the regression can be clearly seen.
```gd
extends Control
var split_containers: Array[HSplitContainer] = []
var time := 0.0
func _ready() -> void:
anchor_right = 1.0
anchor_bottom = 1.0
var split := HSplitContainer.new()
split.name = "TestSplitContainer"
split.anchor_right = 1.0
split.anchor_bottom = 1.0
split.size_flags_horizontal = Control.SIZE_EXPAND_FILL
split.size_flags_vertical = Control.SIZE_EXPAND_FILL
split.split_offset = 200
var left := PanelContainer.new()
left.custom_minimum_size = Vector2(100, 0)
left.size_flags_horizontal = Control.SIZE_EXPAND_FILL
left.size_flags_vertical = Control.SIZE_EXPAND_FILL
var left_label := Label.new()
left_label.text = "Left panel"
left_label.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER
left_label.vertical_alignment = VERTICAL_ALIGNMENT_CENTER
left.add_child(left_label)
var right := PanelContainer.new()
right.custom_minimum_size = Vector2(100, 0)
right.size_flags_horizontal = Control.SIZE_EXPAND_FILL
right.size_flags_vertical = Control.SIZE_EXPAND_FILL
var right_label := Label.new()
right_label.text = "Right panel"
right_label.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER
right_label.vertical_alignment = VERTICAL_ALIGNMENT_CENTER
right.add_child(right_label)
split.add_child(left)
split.add_child(right)
add_child(split)
split_containers.append(split)
func _process(delta: float) -> void:
time += delta
var offset := int(300.0 + sin(time * 2.0) * 200.0)
split_containers[0].split_offsets[0] = offset
```
### Minimal reproduction project (MRP)
This is the test project shown in the afformentioned videos.
[split-container-test.zip](https://github.com/user-attachments/files/29110514/split-container-test.zip)
Contributor guide
Research direction
Start with the attached minimal reproduction project and compare indexed split_offsets assignment in Godot 4.6 and 4.7. Then trace the SplitContainer implementation and split_offsets entry point to identify why the indexed update is not reflected. Done means the assignment updates both the stored value and visible split position without relying on deprecated split_offset.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- game-dev
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 68/100