From a5517313d2ced945d20cc7c58308be2e75072b5b Mon Sep 17 00:00:00 2001 From: Alexander Montag Date: Mon, 2 Sep 2024 10:27:22 +0200 Subject: [PATCH] Fix editor setting initialization for GDExtensions This commit addresses an issue where editor settings were not properly initialized when using GDExtensions. The problem manifested as an error message: "Condition '!props.has(pinfo.name)' is true" when trying to access the "limbo_ai/editor/layout" setting. Changes: - Replace Dictionary with PropertyInfo for adding property information - Add a safeguard to ensure the setting is explicitly set if not present --- editor/limbo_ai_editor_plugin.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/editor/limbo_ai_editor_plugin.cpp b/editor/limbo_ai_editor_plugin.cpp index fb9b9e7..d20009f 100644 --- a/editor/limbo_ai_editor_plugin.cpp +++ b/editor/limbo_ai_editor_plugin.cpp @@ -1464,12 +1464,17 @@ LimboAIEditor::LimboAIEditor() { EDITOR_SETTINGS()->add_property_hint(PropertyInfo(Variant::INT, "limbo_ai/editor/layout", PROPERTY_HINT_ENUM, "Classic:0,Widescreen Optimized:1")); EDITOR_SETTINGS()->set_restart_if_changed("limbo_ai/editor/layout", true); #elif LIMBOAI_GDEXTENSION - Dictionary pinfo; - pinfo["name"] = "limbo_ai/editor/layout"; - pinfo["type"] = Variant::INT; - pinfo["hint"] = PROPERTY_HINT_ENUM; - pinfo["hint_string"] = "Classic:0,Widescreen Optimized:1"; + PropertyInfo pinfo; + pinfo.name = "limbo_ai/editor/layout"; + pinfo.type = Variant::INT; + pinfo.hint = PROPERTY_HINT_ENUM; + pinfo.hint_string = "Classic:0,Widescreen Optimized:1"; EDITOR_SETTINGS()->add_property_info(pinfo); + + // Hotfix: Ensure the property is set (EditorInterface->get_singleton()->set_initial_value(m_setting, m_value, false) appears insufficient.) + if (!EDITOR_SETTINGS()->has_setting("limbo_ai/editor/layout")) { + EDITOR_SETTINGS()->set_setting("limbo_ai/editor/layout", 0); + } #endif LW_SHORTCUT("limbo_ai/rename_task", TTR("Rename"), LW_KEY(F2));