Fix #527
When in editor, all scripts in a scene are placeholders (except if a script is in Tool mode, which we don't support)
The code responsible from creating the placeholder was trying to refresh the script default values each time it was called, leading to the use of a null pointer when the KotlinScript didn't have any associated KtClass (as it's the case of any newly created script or project that hasn't built the .jar).
I made the code more robust with the following changes:
A unique refresh of default values in update_exports(), called when scripts are getting reloaded.
Consistent use of "is_valid()" in KotlinScript.
Implemented the fallback method in KotlinScript so PlaceholderInstance won't try to use a script that is not built.
Simplified the loading/reloading of script by merging all previous 3 steps into a single one.
Scripts are now only stored in TypeManager, no duplicates in GdKotlin or KotlinScriptCache.
Script loading doesn't depend on the ResourceLoader anymore.
This PR doesn't solve the issues with the Create/Attach Script UI, but it should prevent a number of crashes caused by it.
Fix #527 When in editor, all scripts in a scene are placeholders (except if a script is in Tool mode, which we don't support) The code responsible from creating the placeholder was trying to refresh the script default values each time it was called, leading to the use of a null pointer when the KotlinScript didn't have any associated KtClass (as it's the case of any newly created script or project that hasn't built the .jar).
I made the code more robust with the following changes:
This PR doesn't solve the issues with the Create/Attach Script UI, but it should prevent a number of crashes caused by it.