From 866452c75e061b857232ee1dc26969e46fa7bcaa Mon Sep 17 00:00:00 2001 From: ajreckof Date: Fri, 5 Apr 2024 16:42:21 +0200 Subject: [PATCH] Fix crash on invalid values in EditorPropertyArray/Dict --- editor/editor_properties_array_dict.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/editor/editor_properties_array_dict.cpp b/editor/editor_properties_array_dict.cpp index a6c7d6b617d..632deecbb9a 100644 --- a/editor/editor_properties_array_dict.cpp +++ b/editor/editor_properties_array_dict.cpp @@ -328,6 +328,7 @@ void EditorPropertyArray::update_property() { memdelete(container); button_add_item = nullptr; container = nullptr; + slots.clear(); } return; } @@ -586,7 +587,7 @@ void EditorPropertyArray::_edit_pressed() { Variant array = get_edited_property_value(); if (!array.is_array() && edit->is_pressed()) { initialize_array(array); - get_edited_object()->set(get_edited_property(), array); + emit_changed(get_edited_property(), array); } get_edited_object()->editor_set_section_unfold(get_edited_property(), edit->is_pressed()); @@ -867,7 +868,7 @@ void EditorPropertyDictionary::setup(PropertyHint p_hint) { void EditorPropertyDictionary::update_property() { Variant updated_val = get_edited_property_value(); - if (updated_val.get_type() == Variant::NIL) { + if (updated_val.get_type() != Variant::DICTIONARY) { edit->set_text(TTR("Dictionary (Nil)")); // This provides symmetry with the array property. edit->set_pressed(false); if (container) { @@ -875,6 +876,7 @@ void EditorPropertyDictionary::update_property() { memdelete(container); button_add_item = nullptr; container = nullptr; + slots.clear(); } return; } @@ -1021,7 +1023,7 @@ void EditorPropertyDictionary::_edit_pressed() { Variant prop_val = get_edited_property_value(); if (prop_val.get_type() == Variant::NIL && edit->is_pressed()) { VariantInternal::initialize(&prop_val, Variant::DICTIONARY); - get_edited_object()->set(get_edited_property(), prop_val); + emit_changed(get_edited_property(), prop_val); } get_edited_object()->editor_set_section_unfold(get_edited_property(), edit->is_pressed());