From 18e66e9af1bffd2e58dfa1d96ee2604220588aed Mon Sep 17 00:00:00 2001 From: JeremyStarTM Date: Sat, 6 Apr 2024 13:12:49 +0200 Subject: [PATCH] Fix crashes --- src/sms.gd | 2 +- src/storage.gd | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/sms.gd b/src/sms.gd index 57b8d4d..80c94c4 100644 --- a/src/sms.gd +++ b/src/sms.gd @@ -47,7 +47,7 @@ func _cleanup() -> void: func _pull_config() -> void: if core.config.headless: # Remove all scenes - logger.verbf("sms", "Removing all scenes (triggered by headless mode)") + if is_inside_tree(): logger.verbf("sms", "Removing all scenes (triggered by headless mode)") for scene in scenes: remove_scene(scene, true) # Add a scene to some scene collection diff --git a/src/storage.gd b/src/storage.gd index b4d4ed9..d413ac4 100644 --- a/src/storage.gd +++ b/src/storage.gd @@ -92,11 +92,11 @@ func nuke_storage(autosave: bool = true) -> bool: if autosave: save_storage() return true -func get_key(key: String, default: Variant) -> Variant: +func get_key(key: String, default: Variant = null) -> Variant: if !is_open: logger.errorf("storage", "Failed to get key: No storage file is open") return NAN - logger.diagf("storage", "Returning storage key \"" + key + "\" (default='" + default + "')") + logger.diagf("storage", "Returning storage key \"" + key + "\" (default='" + str(default) + "')") return storage.get(key, default) func set_key(key: String, value: Variant, overwrite: bool = true, autosave: bool = true) -> bool: