Godot Engine – Multi-platform 2D and 3D game engine
Don't allow setting a theme type's base type as itself
AegisTTN1a306ae6989a
diff --git a/editor/scene/gui/theme_editor_plugin.cpp b/editor/scene/gui/theme_editor_plugin.cppindex c137a376bf3..417a6245328 100644--- a/editor/scene/gui/theme_editor_plugin.cpp+++ b/editor/scene/gui/theme_editor_plugin.cpp@@ -2384,8 +2384,8 @@ void ThemeTypeDialog::_add_type_selected(const String &p_type_name) {}void ThemeTypeDialog::_add_type_confirmed() {- emit_signal(SNAME("type_selected"), pre_submitted_value);hide();+ emit_signal(SNAME("type_selected"), pre_submitted_value);}void ThemeTypeDialog::_notification(int p_what) {@@ -3667,6 +3667,14 @@ void ThemeTypeEditor::_update_stylebox_from_leading() {void ThemeTypeEditor::_type_variation_changed(const String p_value) {EditorUndoRedoManager *ur = EditorUndoRedoManager::get_singleton();++ if (p_value == edited_type) {+ type_variation_edit->unedit();+ type_variation_edit->set_text(edited_theme->get_type_variation_base(edited_type));+ EditorNode::get_singleton()->show_warning(TTR("A type cannot be set as a variation of itself."));+ return;+ }+ur->create_action(TTR("Set Theme Type Variation"));if (p_value.is_empty()) {diff --git a/scene/resources/theme.cpp b/scene/resources/theme.cppindex 8ebd32d3d6a..40e1e0629f6 100644--- a/scene/resources/theme.cpp+++ b/scene/resources/theme.cpp@@ -1408,6 +1408,7 @@ void Theme::set_type_variation(const StringName &p_theme_type, const StringNameERR_FAIL_COND_MSG(p_theme_type == StringName(), vformat("An empty theme type cannot be marked as a variation of another type (\"%s\").", p_base_type));ERR_FAIL_COND_MSG(ClassDB::class_exists(p_theme_type), vformat("A type associated with a built-in class cannot be marked as a variation of another type (variation: \"%s\", base: \"%s\").", p_theme_type, p_base_type));ERR_FAIL_COND_MSG(p_base_type == StringName(), "An empty theme type cannot be the base type of a variation. Use clear_type_variation() instead if you want to unmark '" + String(p_theme_type) + "' as a variation.");+ ERR_FAIL_COND_MSG(p_base_type == p_theme_type, "A type cannot be set as a variation of itself.");if (variation_map.has(p_theme_type)) {StringName old_base = variation_map[p_theme_type];