diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2024-04-05 17:23:00 +0200 |
---|---|---|
committer | Rémi Verschelde <rverschelde@gmail.com> | 2024-04-05 17:23:00 +0200 |
commit | c493217947e645c89a095491b7fae87a2ad07710 (patch) | |
tree | 4fa99ff8d167b49a47a8775bedf16801ad35dda1 | |
parent | a8e7688b67a7d99153ffe8bc07c06ea58ef6989b (diff) | |
parent | 866452c75e061b857232ee1dc26969e46fa7bcaa (diff) | |
download | redot-engine-c493217947e645c89a095491b7fae87a2ad07710.tar.gz |
Merge pull request #90265 from ajreckof/Fix-crash-on-invalid-values-in-EditorPropertyArray/Dict
Fix crash on invalid values in EditorPropertyArray/Dict
-rw-r--r-- | editor/editor_properties_array_dict.cpp | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/editor/editor_properties_array_dict.cpp b/editor/editor_properties_array_dict.cpp index a6c7d6b617..632deecbb9 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()); |