You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-04 12:00:25 +00:00
GDScript: Initialize static variables with defaults in-editor
When the script is not marked as `@tool` the static constructor is not called and thus the variables contain `null` by default. But since some validated operations requires a valid value, this would cause a crash. This commit solves this by initializing the static variables with a default value based on their types in the editor, when they are not marked as `@tool`, so if some `@tool` script access them, they will have a valid typed value, avoiding the crash.
This commit is contained in:
@@ -169,6 +169,9 @@ private:
|
||||
GDScriptFunction *static_initializer = nullptr;
|
||||
|
||||
Error _static_init();
|
||||
#ifdef TOOLS_ENABLED
|
||||
void _static_default_init(); // Initialize static variables with default values based on their types.
|
||||
#endif
|
||||
|
||||
int subclass_count = 0;
|
||||
RBSet<Object *> instances;
|
||||
|
||||
Reference in New Issue
Block a user