diff options
author | Bojidar Marinov <bojidar.marinov.bg@gmail.com> | 2019-02-26 14:58:39 +0200 |
---|---|---|
committer | Bojidar Marinov <bojidar.marinov.bg@gmail.com> | 2019-02-26 14:58:39 +0200 |
commit | db7864c1fd852416f2ada7038bfbf71813904174 (patch) | |
tree | 39578a8f441295c3682664a807a07289a0847b34 /editor | |
parent | 22ee7ba4f083fdfab1c177fcd8d921736b5a91ca (diff) |
Fix GDScript exports having the wrong type of default value by converting it
Also, initialize elements of PoolArrays when resizing them in the editor.
Fixes #26066.
Diffstat (limited to 'editor')
-rw-r--r-- | editor/editor_properties_array_dict.cpp | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/editor/editor_properties_array_dict.cpp b/editor/editor_properties_array_dict.cpp index 0851485208..0f6c6349ed 100644 --- a/editor/editor_properties_array_dict.cpp +++ b/editor/editor_properties_array_dict.cpp @@ -418,13 +418,14 @@ void EditorPropertyArray::_length_changed(double p_page) { return; Variant array = object->get_array(); + int previous_size = array.call("size"); + array.call("resize", int(p_page)); - emit_changed(get_edited_property(), array, "", false); if (array.get_type() == Variant::ARRAY) { if (subtype != Variant::NIL) { int size = array.call("size"); - for (int i = 0; i < size; i++) { + for (int i = previous_size; i < size; i++) { if (array.get(i).get_type() == Variant::NIL) { Variant::CallError ce; array.set(i, Variant::construct(subtype, NULL, 0, ce)); @@ -432,7 +433,16 @@ void EditorPropertyArray::_length_changed(double p_page) { } } array = array.call("duplicate"); //dupe, so undo/redo works better + } else { + int size = array.call("size"); + // Pool*Array don't initialize their elements, have to do it manually + for (int i = previous_size; i < size; i++) { + Variant::CallError ce; + array.set(i, Variant::construct(array.get(i).get_type(), NULL, 0, ce)); + } } + + emit_changed(get_edited_property(), array, "", false); object->set_array(array); update_property(); } |