PunchablePlushie/godot-game-settings

Adding new properties crashes the addon

Closed this issue · 3 comments

Adding a new settings property to the possibilities can crash the addon.

When there is an existing saved settings resource changing the game and adding a new setting makes the addon search for that category and setting inside that category. When it cannot find that it crashes the addon and the game as well. As far as I can tell, changing the save file in a way that the format is changed so that the addon cannot read it properly crashes it.

Adding a failsafe to instead delete this badly formatted file and recreate one based on the defaults might be the proper way to handle it.

(Awesome plugin btw, thank you!)

Could you provide the steps to reproduce the bug? And glad the plugin's useful to you!

It seems there was a missing default set and that is why the missing property in the save file caused a crash. We were trying to sync across multiple PCs and that is when this problem came up.

It is not clear though where the default is stored. There is a default entry in the tscn file of the UI scene and there is one in the plugin_data.tres under the addon folder.

The plugin uses data from plugin_data.tres to get the default value when a setting doesn't already exist in the save file. So that's where you should be checking. As long as the subresource of your setting in plugin data has a valid default value (not null and compatible with the type that the apply() method of the setting expects), there shouldn't be any crashes when a setting entry is missing from the save file as the plugin will simply use that valid default to add the missing entry to the file.

I recommend opening plugin_data.tres with an external editor, searching for your setting name, and checking if the default property of the subresource is properly set to something valid instead of null.

Sharing the error message, when it occurs during runtime (e.g. at startup, when entering the UI scene, etc.), and where it points to in the code could help me understand the issue more as well.