Skip to content

Commit

Permalink
keep type after adding item
Browse files Browse the repository at this point in the history
  • Loading branch information
ajreckof committed Apr 15, 2023
1 parent db69456 commit 94c5e76
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions editor/editor_properties_array_dict.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -794,10 +794,21 @@ void EditorPropertyDictionary::_add_key_value() {
}

Dictionary dict = object->get_dict().duplicate();
dict[object->get_new_item_key()] = object->get_new_item_value();
object->set_new_item_key(Variant());
object->set_new_item_value(Variant());

Variant new_key = object->get_new_item_key();
if (!dict.has(new_key)) {
Variant new_value = object->get_new_item_value();
dict[new_key] = new_value;

Variant::Type type = new_key.get_type();
new_key.zero();
VariantInternal::initialize(&new_key, type);
object->set_new_item_key(new_key);

type = new_value.get_type();
new_value.zero();
VariantInternal::initialize(&new_value, type);
object->set_new_item_value(new_value);
}
emit_changed(get_edited_property(), dict, "", false);
update_property();
}
Expand Down

0 comments on commit 94c5e76

Please sign in to comment.