From bf15aa0f871ff5358e41f1334861ac5b153bb4e1 Mon Sep 17 00:00:00 2001 From: Relintai Date: Sun, 25 Feb 2024 22:34:48 +0100 Subject: [PATCH] Don't create empty keys. --- modules/web/html/html_template.cpp | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/modules/web/html/html_template.cpp b/modules/web/html/html_template.cpp index 1300d601b..00216cc71 100644 --- a/modules/web/html/html_template.cpp +++ b/modules/web/html/html_template.cpp @@ -279,11 +279,13 @@ void HTMLTemplate::_on_editor_template_button_pressed(const StringName &p_proper if (scount == 2) { // This way add_key can also be used as a key if (key == "add_key_button") { - _template_overrides[_editor_new_template_override_key] = ""; + if (!_editor_new_template_override_key.empty()) { + _template_overrides[_editor_new_template_override_key] = ""; - _editor_new_template_override_key = ""; + _editor_new_template_override_key = ""; - property_list_changed_notify(); + property_list_changed_notify(); + } } return; @@ -296,7 +298,7 @@ void HTMLTemplate::_on_editor_template_button_pressed(const StringName &p_proper property_list_changed_notify(); } - return ; + return; } if (name.begins_with("template_defaults/")) { @@ -307,11 +309,13 @@ void HTMLTemplate::_on_editor_template_button_pressed(const StringName &p_proper if (scount == 2) { // This way add_key can also be used as a key if (key == "add_key_button") { - _template_defaults[_editor_new_template_default_key] = ""; + if (!_editor_new_template_default_key.empty()) { + _template_defaults[_editor_new_template_default_key] = ""; - _editor_new_template_default_key = ""; + _editor_new_template_default_key = ""; - property_list_changed_notify(); + property_list_changed_notify(); + } return; }