-
-
Notifications
You must be signed in to change notification settings - Fork 572
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
Global godot-type variable cause crash and load gdextension failed #1449
Comments
Well, we can't make Godot types work if they are constructed before the GDExtension has been initialized. It would be nice to not crash, although, I'm not sure how feasible that is. We could wrap everything in a check to see if it's been initialized yet, and then output a message, I guess? |
There maybe two types that need to be checked:
Checking if they are nullptr (or assignment placeholder) requires writing a big logic and the final outcome still cannot declare global variables. I think it's better to not solved it (global variable not many usage scenarios and it's not necessary). |
Doing some experimentation, one type of static storage does work: static variables inside of functions. int Foo::get_increment()
{
static int counter {0};
++counter;
return counter;
} |
Yes, if the function is called after the GDExtension has been initialized, that should work. |
From my comment on #1557:
I'm starting to think that maybe we should try to implement nr 2? Using This limitation is also something that could use to be documented somewhere. |
I think we can initialize the gdextension-interface function pointer as a |
Ooo, that's an interesting idea! However, it would be nice to say in the error message the name of the object that's being constructed, and I think the only way to do that would be to have a |
Godot version
4.3.dev(11d3768)
godot-cpp version
4.3.dev(e23b117)
System information
win11
Issue description
This issue have existed for a long time, The reproduction steps are the same as this comment: #358 (comment).
This issue is quite tricky, as it is caused by godot load gdextension .dll and initializate GDExtensionInterface
order.
Do need to solve this problem?
Steps to reproduce
Define a global variable
String
, open godot.exe timeline:String
construct GDExtensionInterface(not initialzed and will Crash)Minimal reproduction project
N/A
The text was updated successfully, but these errors were encountered: