Skip to content

Conversation

@TheAenema
Copy link
Contributor

@TheAenema TheAenema commented Feb 2, 2026

The editor currently doesn’t respect PropertyInfo usage flags when adding new Editor Settings through GDExtension. It always assigns a default usage value, which triggers warnings on startup.

This PR adds a check for PROPERTY_USAGE_NONE and skips setting the usage field entirely in that case, preventing the warning from being generated at startup.

if (usage != PROPERTY_USAGE_NONE) {
    dict["usage"] = usage;
}

Summary by CodeRabbit

  • Bug Fixes
    • Property information serialization now omits default values, reducing unnecessary data in serialized output.

@coderabbitai
Copy link

coderabbitai bot commented Feb 2, 2026

📝 Walkthrough

Walkthrough

Modified PropertyInfo's to_dict() serialization to conditionally include the "usage" field only when usage is not PROPERTY_USAGE_NONE, reducing unnecessary data in serialized dictionaries for properties with default usage values.

Changes

Cohort / File(s) Summary
PropertyInfo Serialization
include/godot_cpp/core/property_info.hpp
Modified to_dict() to conditionally include "usage" field only when usage is not PROPERTY_USAGE_NONE, avoiding redundant default values in serialized output.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Poem

🐰 A PropertyInfo cleaned its pack,
Removing "usage" when defaults came back,
Smaller dicts now skip what's not needed—
Our efficiency plea has succeeded! ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: fixing PropertyInfo's default usage behavior when converting to a Dictionary by conditionally excluding 'usage' when it equals PROPERTY_USAGE_NONE.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@include/godot_cpp/core/property_info.hpp`:
- Around line 83-85: The serialization omits the "usage" key when
PropertyInfo::usage == PROPERTY_USAGE_NONE, but PropertyInfo::from_dict()
currently falls back to PROPERTY_USAGE_DEFAULT when the key is absent, breaking
roundtrip fidelity; update PropertyInfo::from_dict() to set usage to
PROPERTY_USAGE_NONE when the "usage" key is missing (e.g., check
dict.has("usage") or equivalent) so that missing key restores
PROPERTY_USAGE_NONE instead of PROPERTY_USAGE_DEFAULT, referencing the
PropertyInfo struct and its usage field and the constants PROPERTY_USAGE_NONE /
PROPERTY_USAGE_DEFAULT to locate the change.

Comment on lines +83 to +85
if (usage != PROPERTY_USAGE_NONE) {
dict["usage"] = usage;
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Potential roundtrip inconsistency with from_dict().

When usage == PROPERTY_USAGE_NONE, the "usage" key is now omitted from the dictionary. However, from_dict() (lines 106-108) leaves usage at the struct default PROPERTY_USAGE_DEFAULT when the key is missing. This means:

  • PropertyInfo with usage = PROPERTY_USAGE_NONEDictionaryfrom_dict()usage = PROPERTY_USAGE_DEFAULT

If roundtrip fidelity is needed, consider updating from_dict() to default to PROPERTY_USAGE_NONE when the "usage" key is absent:

Proposed fix to align from_dict() behavior
 	static PropertyInfo from_dict(const Dictionary &p_dict) {
 		PropertyInfo pi;
+		pi.usage = PROPERTY_USAGE_NONE; // Match to_dict() behavior when key is missing
 		if (p_dict.has("type")) {
 			pi.type = Variant::Type(int(p_dict["type"]));
 		}
🤖 Prompt for AI Agents
In `@include/godot_cpp/core/property_info.hpp` around lines 83 - 85, The
serialization omits the "usage" key when PropertyInfo::usage ==
PROPERTY_USAGE_NONE, but PropertyInfo::from_dict() currently falls back to
PROPERTY_USAGE_DEFAULT when the key is absent, breaking roundtrip fidelity;
update PropertyInfo::from_dict() to set usage to PROPERTY_USAGE_NONE when the
"usage" key is missing (e.g., check dict.has("usage") or equivalent) so that
missing key restores PROPERTY_USAGE_NONE instead of PROPERTY_USAGE_DEFAULT,
referencing the PropertyInfo struct and its usage field and the constants
PROPERTY_USAGE_NONE / PROPERTY_USAGE_DEFAULT to locate the change.

@Arctis-Fireblight Arctis-Fireblight merged commit e36a8bf into Redot-Engine:master Feb 2, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants