godotengine / godotengine/godot

Checkable properties behave differently based on where they are edited

Open
#99,976 2 comments 0 reactions 0 assignees View on GitHub
bug topic:editor
Dominant language
C++
Stars
117k
Forks
26.8k
PR merge metrics
PR metrics pending

Description

### Tested versions

v4.3.stable.official [77dcf97d8]

### System information

Godot v4.3.stable - Windows 10.0.19045 - Vulkan (Forward+) - dedicated GeForce GTX 1660 Ti - Intel(R) Core(TM) i5-9300HF CPU @ 2.40GHz (8 Threads)

### Issue description

I use "checkable properties" to refer to properties exposed to the editor through `_get_property_list` with the usage flag `PROPERTY_USAGE_CHECKABLE`.

Assume we have the following:
- a custom resource class `MyResource` with a checkable property of type `int`
- a file `my_resource.tres` storing an instance of the resource
- a scene `MyNode` with an exported member of type `MyResource` set to `my_resource.tres`

When editing `my_resource.tres` directly, checking on and off the property work as I expect it to. Specifically, toggling it off sets the value to `null` internally and the editor displays `0`. However, when editing `my_resource.tres` through `MyNode`'s inspector, toggling it on or off does nothing. This doesn't just affect the editor: even if `my_property` is manually set to 0 and unchecked, it will be saved as 0 and not `null` when the two may have different meanings.

In my project, I use checkable properties in a system similar to `Control`'s themes. `null` and only `null` means "don't override the parent's value". As a workaround, I store all such theme-like resources externally.

### Steps to reproduce

The minimal reproduction project below contains all the necessary files to reproduce the issue.

1) Open `my_resource.tres`. Toggling its property on should print `my_property <- 0` to the console (replace 0 with whatever value you've entered if using the spinbox directly). Toggling it off should always display `my_property <- `.
2) Open `my_node.tscn`, and click on its `first` field to edit it. Since its value is set to `my_resource.tres`, I expect it to work just like in the previous case. Instead, toggling the property on or off does nothing. It is possible to input a non-zero value and toggle it off without the value being reset.

### Minimal reproduction project (MRP)

[mrp_checkable_properties.zip](https://github.com/user-attachments/files/17997122/mrp_checkable_properties.zip)

Contributor guide

Open the contributing guide

Research direction

Start with the attached minimal reproduction project, comparing my_resource.tres edited directly with my_node.tscn's nested first resource in the inspector. Reproduce the toggle behavior and trace the editor handling for checkable properties in both contexts. Done means toggling nested properties consistently updates and saves null versus 0 as described.

Written by the indexing model from the issue text.

Assessment

Tech stack
godot
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.