Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GDExtension: Classes without default constructor break reloading #96823

Open
Bromeon opened this issue Sep 10, 2024 · 2 comments · May be fixed by #99133
Open

GDExtension: Classes without default constructor break reloading #96823

Bromeon opened this issue Sep 10, 2024 · 2 comments · May be fixed by #99133

Comments

@Bromeon
Copy link
Contributor

Bromeon commented Sep 10, 2024

Tested versions

4.3-stable and before

System information

All systems

Issue description

GDExtension allows classes to be registered without a default constructor. They can either have custom constructors (static methods) that are invokable from GDScript, or non-exposed constructors only available in the binding language. This can be done by not providing create and recreate function pointers during class registration, and optionally marking a class as abstract.

However, without a recreate callback, Godot emits the error message:

Extension marked as reloadable, but attempted to register class 'MyClass' which doesn't support reloading. Perhaps your language binding don't support it? Reloading disabled for this extension.

This might be a bit too much because:

  • Not having a recreate callback shouldn't be a problem until there are actual instances of such a class to be reloaded.
  • Even then, Godot shouldn't disable reloading for the entire extension just because of one class.

The only workaround seems to be providing a dummy recreate function, although I haven't tested this, and I don't know if it has any other implications.

Steps to reproduce

Set reloadable = true in the .gdextension file.
Register a class in GDExtension with create_instance_func and recreate_instance_func function pointers set to null.

Minimal reproduction project (MRP)

N/A

@dsnopek
Copy link
Contributor

dsnopek commented Nov 12, 2024

I think we should probably update the check in GDExtension::_register_extension_class_internal() to see if the class is creatable in the first place, before deciding the extension can't be reloaded.

@dsnopek
Copy link
Contributor

dsnopek commented Nov 12, 2024

I just posted PR #99133 which should fix this, but I haven't had a chance to do any testing yet

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants