GDExtension: Fix setting base class properties on a runtime class #94089
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #93676
This PR makes it so that placeholders for runtime classes from GDExtension will only try to store properties that are specifically from the runtime class (or any of its parent classes that are also runtime classes).
This fixes #93676 in my testing, but also fixes other issues that I hadn't noticed previously with setting properties on parent classes. For example, before this PR, if you make a runtime class in a GDExtension that extends
Sprite
, then set thetexture
property in the editor, it won't actually display the texture in the editor (but will when loading the saved scene in the running game).Also, while working on this, I realized that we have a difference of behavior between runtime classes defined in modules and those defined in GDExtensions: in a GDExtension, if you make a runtime class that has a non-runtime parent class, it won't run any of the code from that parent class, but only use its native parent; whereas in a module, the parent is always native, and it would always run the parent's code. So, if someone used runtime classes that extended non-runtime classes from their GDExtension, and then moved those classes into a module, they would act differently.
I think it should be possible to make GDExtensions work the same as modules in this regard, and I started hacking on it, but it would be a big patch. So, instead, I've added a new limitation preventing runtime classes defined in GDExtensions from extending from non-runtime extension classes. This way, when we eventually make the changes to correct this behavior difference, we can also remove this limitation, preventing a future change in behavior.