Skip to content

fix: add_components does not set component.parent#114

Open
SAY-5 wants to merge 1 commit into
csprance:mainfrom
SAY-5:fix-add-components-parent
Open

fix: add_components does not set component.parent#114
SAY-5 wants to merge 1 commit into
csprance:mainfrom
SAY-5:fix-add-components-parent

Conversation

@SAY-5

@SAY-5 SAY-5 commented Jun 13, 2026

Copy link
Copy Markdown

add_component sets component.parent = self, but add_components leaves parent unset when storing each component, so components added in a batch report a null parent (#112). This sets parent on the batch path too, and adds a regression test covering it.

Summary by CodeRabbit

  • Bug Fixes

    • Fixed an issue where components added in batch operations were not properly initialized with parent references, ensuring consistent behavior between batch and individual component additions.
  • Tests

    • Added test coverage to verify component parent initialization in batch addition scenarios.

@coderabbitai

coderabbitai Bot commented Jun 13, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: f5729686-85fb-4e1f-8ef2-21fb1004ab5a

📥 Commits

Reviewing files that changed from the base of the PR and between 4a9ab7a and 05fcfa1.

📒 Files selected for processing (2)
  • addons/gecs/ecs/entity.gd
  • addons/gecs/tests/core/test_entity.gd

Walkthrough

The PR fixes a bug in Entity.add_components where batch-added components were not having their parent property set. A single line assignment (component.parent = self) is added to the batch-addition loop, and a new test validates that both components correctly reference the entity as parent.

Changes

Parent assignment in batch component addition

Layer / File(s) Summary
Batch component parent assignment and validation
addons/gecs/ecs/entity.gd, addons/gecs/tests/core/test_entity.gd
The add_components method assigns component.parent = self during batch additions to match single add_component behavior. Test test_add_components_sets_parent confirms components added via add_components correctly reference the entity as parent.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Possibly related issues

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately and concisely describes the main fix: ensuring add_components sets the component.parent property, addressing the core issue in the changeset.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

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.

1 participant