Skip to content

Commit 866452c

Browse files
committed
Fix crash on invalid values in EditorPropertyArray/Dict
1 parent febb11f commit 866452c

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

editor/editor_properties_array_dict.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,7 @@ void EditorPropertyArray::update_property() {
328328
memdelete(container);
329329
button_add_item = nullptr;
330330
container = nullptr;
331+
slots.clear();
331332
}
332333
return;
333334
}
@@ -586,7 +587,7 @@ void EditorPropertyArray::_edit_pressed() {
586587
Variant array = get_edited_property_value();
587588
if (!array.is_array() && edit->is_pressed()) {
588589
initialize_array(array);
589-
get_edited_object()->set(get_edited_property(), array);
590+
emit_changed(get_edited_property(), array);
590591
}
591592

592593
get_edited_object()->editor_set_section_unfold(get_edited_property(), edit->is_pressed());
@@ -867,14 +868,15 @@ void EditorPropertyDictionary::setup(PropertyHint p_hint) {
867868
void EditorPropertyDictionary::update_property() {
868869
Variant updated_val = get_edited_property_value();
869870

870-
if (updated_val.get_type() == Variant::NIL) {
871+
if (updated_val.get_type() != Variant::DICTIONARY) {
871872
edit->set_text(TTR("Dictionary (Nil)")); // This provides symmetry with the array property.
872873
edit->set_pressed(false);
873874
if (container) {
874875
set_bottom_editor(nullptr);
875876
memdelete(container);
876877
button_add_item = nullptr;
877878
container = nullptr;
879+
slots.clear();
878880
}
879881
return;
880882
}
@@ -1021,7 +1023,7 @@ void EditorPropertyDictionary::_edit_pressed() {
10211023
Variant prop_val = get_edited_property_value();
10221024
if (prop_val.get_type() == Variant::NIL && edit->is_pressed()) {
10231025
VariantInternal::initialize(&prop_val, Variant::DICTIONARY);
1024-
get_edited_object()->set(get_edited_property(), prop_val);
1026+
emit_changed(get_edited_property(), prop_val);
10251027
}
10261028

10271029
get_edited_object()->editor_set_section_unfold(get_edited_property(), edit->is_pressed());

0 commit comments

Comments
 (0)