Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Packed array properties of noncustom resources can't be resized #80950

Closed
OffsetMOSFET opened this issue Aug 24, 2023 · 8 comments
Closed

Packed array properties of noncustom resources can't be resized #80950

OffsetMOSFET opened this issue Aug 24, 2023 · 8 comments

Comments

@OffsetMOSFET
Copy link

Godot version

4.1.stable

System information

Godot v4.1.stable - Windows 10.0.19044 - Vulkan (Forward+) - dedicated Quadro P2200 () - Intel(R) Xeon(R) Gold 5222 CPU @ 3.80GHz (8 Threads)

Issue description

For Godot (not custom) Resources, a property that is a PackedArray cannot be resized directly. Copying, resizing, then setting the copy currently works as a work-around.

This behavior is different from custom Resource classes that are built in GDScript instead of C++. These allow resizing of PackedArray properties directly.

Steps to reproduce

Put the attached bug_script.gd code a Control node of a new scene, copy the custom class script gd_custom_class.gd as its own file, then run the scene. The output will mark the point of discrepency.

Output:

Property init size: 0
Propety resized size: 0 (Expected 10)
Array init size: 0
Array resized size: 10
Property reassigned size 10
-
Property init size: 0
Propety resized size: 0 (Expected 11)
Array init size: 0
Array resized size: 11
Property reassigned size 11
-
Property init size: 0
Propety resized size: 0 (Expected 12)
Array init size: 0
Array resized size: 12
Property reassigned size 12
-
Property init size: 0
Propety resized size: 13 (Expected 13)
Array init size: 0
Array resized size: 13
Property reassigned size 13

Minimal reproduction project

bug_script.gd

extends Control

var res0 := StreamPeerBuffer.new()
var res1 := OggPacketSequence.new()
var res2 := ArrayOccluder3D.new()
var res3 := GDCustomClass.new()

func _ready():
	print("Property init size: " + str(res0.data_array.size()))
	res0.data_array.resize(10)
	print("Propety resized size: " + str(res0.data_array.size()) + " (Expected 10)")
	var new_array0 := PackedByteArray()
	print("Array init size: " + str(new_array0.size()))
	new_array0.resize(10)
	print("Array resized size: " + str(new_array0.size()))
	res0.data_array = new_array0
	print("Property reassigned size " + str(res0.data_array.size()))

	print("-")

	print("Property init size: " + str(res1.granule_positions.size()))
	res1.granule_positions.resize(11)
	print("Propety resized size: " + str(res1.granule_positions.size()) + " (Expected 11)")
	var new_array1 := PackedInt64Array()
	print("Array init size: " + str(new_array1.size()))
	new_array1.resize(11)
	print("Array resized size: " + str(new_array1.size()))
	res1.granule_positions = new_array1
	print("Property reassigned size " + str(res1.granule_positions.size()))
	
	print("-")
	
	print("Property init size: " + str(res2.indices.size()))
	res2.indices.resize(12)
	print("Propety resized size: " + str(res2.indices.size()) + " (Expected 12)")
	var new_array2 := PackedInt32Array()
	print("Array init size: " + str(new_array2.size()))
	new_array2.resize(12)
	print("Array resized size: " + str(new_array2.size()))
	res2.indices = new_array2
	print("Property reassigned size " + str(res2.indices.size()))
	
	print("-")
	
	print("Property init size: " + str(res3.packed_byte_array.size()))
	res3.packed_byte_array.resize(13)
	print("Propety resized size: " + str(res3.packed_byte_array.size()) + " (Expected 13)")
	var new_array3 := PackedByteArray()
	print("Array init size: " + str(new_array3.size()))
	new_array3.resize(13)
	print("Array resized size: " + str(new_array3.size()))
	res3.packed_byte_array = new_array3
	print("Property reassigned size " + str(res3.packed_byte_array.size()))

gd_custom_class.gd

class_name GDCustomClass
extends Resource

@export var packed_byte_array : PackedByteArray
@dalexeev
Copy link
Member

dalexeev commented Aug 24, 2023

I don't think there is a bug in GDScript. Godot properties in C++ are just setter and getter. Arrays (including Packed*Arrays) are passed by reference. Unlike objects, they do not have signals to track external changes.

The built-in classes you listed do not return a direct reference to the data array (they use other structures under the hood). When the getter is called, a new PackedByteArray is created and data from this structure is written to it, and when the setter is called, the array is validated and written to the structure.

Here is an example in GDScript:

var data: PackedByteArray:
    set(value):
        _data = value.duplicate()
    get:
        return _data.duplicate()

var _data: PackedByteArray

Accordingly, you call resize() not on the internal data structure, but only on the temporary array returned by the getter.

I agree that the current API misleading and probably this should not be exposed as data property, but should be two separate methods set_data() and get_data(). However, we can't remove the property due to compatibility. We should add a note to the documentation for such properties.

@AThousandShips
Copy link
Member

This is documented for Gradient similar can be applied elsewhere

@dalexeev
Copy link
Member

dalexeev commented Aug 24, 2023

<member .* type="(Packed.*Array|Array|Dictionary|.*\[\])"

235 matches, some false positives
doc/classes/AnimationLibrary.xml: 1
 58:  3: 		<member name="_data" type="Dictionary" setter="_set_data" getter="_get_data" default="{}">
doc/classes/ArrayOccluder3D.xml: 2
 24:  3: 		<member name="indices" type="PackedInt32Array" setter="set_indices" getter="get_indices" default="PackedInt32Array()">
 28:  3: 		<member name="vertices" type="PackedVector3Array" setter="set_vertices" getter="get_vertices" default="PackedVector3Array()">
doc/classes/AudioStreamWAV.xml: 1
 23:  3: 		<member name="data" type="PackedByteArray" setter="set_data" getter="get_data" default="PackedByteArray()">
doc/classes/CPUParticles2D.xml: 3
153:  3: 		<member name="emission_colors" type="PackedColorArray" setter="set_emission_colors" getter="get_emission_colors">
156:  3: 		<member name="emission_normals" type="PackedVector2Array" setter="set_emission_normals" getter="get_emission_normals">
159:  3: 		<member name="emission_points" type="PackedVector2Array" setter="set_emission_points" getter="get_emission_points">
doc/classes/CPUParticles3D.xml: 3
158:  3: 		<member name="emission_colors" type="PackedColorArray" setter="set_emission_colors" getter="get_emission_colors" default="PackedColorArray()">
162:  3: 		<member name="emission_normals" type="PackedVector3Array" setter="set_emission_normals" getter="get_emission_normals">
165:  3: 		<member name="emission_points" type="PackedVector3Array" setter="set_emission_points" getter="get_emission_points">
doc/classes/CharFXTransform.xml: 1
 21:  3: 		<member name="env" type="Dictionary" setter="set_environment" getter="get_environment" default="{}">
doc/classes/CodeEdit.xml: 6
458:  3: 		<member name="auto_brace_completion_pairs" type="Dictionary" setter="set_auto_brace_completion_pairs" getter="get_auto_brace_completion_pairs" default="{ &quot;\&quot;&quot;: &quot;\&quot;&quot;, &quot;&apos;&quot;: &quot;&apos;&quot;, &q
464:  3: 		<member name="code_completion_prefixes" type="String[]" setter="set_code_completion_prefixes" getter="get_code_completion_prefixes" default="[]">
467:  3: 		<member name="delimiter_comments" type="String[]" setter="set_comment_delimiters" getter="get_comment_delimiters" default="[]">
470:  3: 		<member name="delimiter_strings" type="String[]" setter="set_string_delimiters" getter="get_string_delimiters" default="[&quot;&apos; &apos;&quot;, &quot;\&quot; \&quot;&quot;]">
494:  3: 		<member name="indent_automatic_prefixes" type="String[]" setter="set_auto_indent_prefixes" getter="get_auto_indent_prefixes" default="[&quot;:&quot;, &quot;{&quot;, &quot;[&quot;, &quot;(&quot;]">
507:  3: 		<member name="line_length_guidelines" type="int[]" setter="set_line_length_guidelines" getter="get_line_length_guidelines" default="[]">
doc/classes/CodeHighlighter.xml: 3
119:  3: 		<member name="color_regions" type="Dictionary" setter="set_color_regions" getter="get_color_regions" default="{}">
125:  3: 		<member name="keyword_colors" type="Dictionary" setter="set_keyword_colors" getter="get_keyword_colors" default="{}">
128:  3: 		<member name="member_keyword_colors" type="Dictionary" setter="set_member_keyword_colors" getter="get_member_keyword_colors" default="{}">
doc/classes/CollisionPolygon2D.xml: 1
 26:  3: 		<member name="polygon" type="PackedVector2Array" setter="set_polygon" getter="get_polygon" default="PackedVector2Array()">
doc/classes/CollisionPolygon3D.xml: 1
 22:  3: 		<member name="polygon" type="PackedVector2Array" setter="set_polygon" getter="get_polygon" default="PackedVector2Array()">
doc/classes/ConcavePolygonShape2D.xml: 1
 16:  3: 		<member name="segments" type="PackedVector2Array" setter="set_segments" getter="get_segments" default="PackedVector2Array()">
doc/classes/ConvexPolygonShape2D.xml: 1
 24:  3: 		<member name="points" type="PackedVector2Array" setter="set_points" getter="get_points" default="PackedVector2Array()">
doc/classes/ConvexPolygonShape3D.xml: 1
 16:  3: 		<member name="points" type="PackedVector3Array" setter="set_points" getter="get_points" default="PackedVector3Array()">
doc/classes/EditorFileDialog.xml: 1
 72:  3: 		<member name="filters" type="PackedStringArray" setter="set_filters" getter="get_filters" default="PackedStringArray()">
doc/classes/FileDialog.xml: 1
 73:  3: 		<member name="filters" type="PackedStringArray" setter="set_filters" getter="get_filters" default="PackedStringArray()">
doc/classes/Font.xml: 1
338:  3: 		<member name="fallbacks" type="Font[]" setter="set_fallbacks" getter="get_fallbacks" default="[]">
doc/classes/FontFile.xml: 2
585:  3: 		<member name="data" type="PackedByteArray" setter="set_data" getter="get_data" default="PackedByteArray()">
623:  3: 		<member name="opentype_feature_overrides" type="Dictionary" setter="set_opentype_feature_overrides" getter="get_opentype_feature_overrides" default="{}">
doc/classes/FontVariation.xml: 2
 49:  3: 		<member name="opentype_features" type="Dictionary" setter="set_opentype_features" getter="get_opentype_features" default="{}">
 71:  3: 		<member name="variation_opentype" type="Dictionary" setter="set_variation_opentype" getter="get_variation_opentype" default="{}">
doc/classes/Gradient.xml: 2
 80:  3: 		<member name="colors" type="PackedColorArray" setter="set_colors" getter="get_colors" default="PackedColorArray(0, 0, 0, 1, 1, 1, 1, 1)">
 91:  3: 		<member name="offsets" type="PackedFloat32Array" setter="set_offsets" getter="get_offsets" default="PackedFloat32Array(0, 1)">
doc/classes/HeightMapShape3D.xml: 1
 13:  3: 		<member name="map_data" type="PackedFloat32Array" setter="set_map_data" getter="get_map_data" default="PackedFloat32Array(0, 0, 0, 0)">
doc/classes/Image.xml: 1
566:  3: 		<member name="data" type="Dictionary" setter="_set_data" getter="_get_data" default="{ &quot;data&quot;: PackedByteArray(), &quot;format&quot;: &quot;Lum8&quot;, &quot;height&quot;: 0, &quot;mipmaps&quot;: false, &q
doc/classes/ImporterMesh.xml: 1
195:  3: 		<member name="_data" type="Dictionary" setter="_set_data" getter="_get_data" default="{ &quot;surfaces&quot;: [] }">
doc/classes/Label.xml: 2
 71:  3: 		<member name="structured_text_bidi_override_options" type="Array" setter="set_structured_text_bidi_override_options" getter="get_structured_text_bidi_override_options" default="[]">
 74:  3: 		<member name="tab_stops" type="PackedFloat32Array" setter="set_tab_stops" getter="get_tab_stops" default="PackedFloat32Array()">
doc/classes/Label3D.xml: 1
118:  3: 		<member name="structured_text_bidi_override_options" type="Array" setter="set_structured_text_bidi_override_options" getter="get_structured_text_bidi_override_options" default="[]">
doc/classes/Line2D.xml: 1
 80:  3: 		<member name="points" type="PackedVector2Array" setter="set_points" getter="get_points" default="PackedVector2Array()">
doc/classes/LineEdit.xml: 1
286:  3: 		<member name="structured_text_bidi_override_options" type="Array" setter="set_structured_text_bidi_override_options" getter="get_structured_text_bidi_override_options" default="[]">
doc/classes/LinkButton.xml: 1
 21:  3: 		<member name="structured_text_bidi_override_options" type="Array" setter="set_structured_text_bidi_override_options" getter="get_structured_text_bidi_override_options" default="[]">
doc/classes/MultiMesh.xml: 5
 91:  3: 		<member name="buffer" type="PackedFloat32Array" setter="set_buffer" getter="get_buffer" default="PackedFloat32Array()">
 93:  3: 		<member name="color_array" type="PackedColorArray" setter="_set_color_array" getter="_get_color_array" is_deprecated="true">
 96:  3: 		<member name="custom_data_array" type="PackedColorArray" setter="_set_custom_data_array" getter="_get_custom_data_array" is_deprecated="true">
107:  3: 		<member name="transform_2d_array" type="PackedVector2Array" setter="_set_transform_2d_array" getter="_get_transform_2d_array" is_deprecated="true">
110:  3: 		<member name="transform_array" type="PackedVector3Array" setter="_set_transform_array" getter="_get_transform_array" is_deprecated="true">
doc/classes/NavigationObstacle2D.xml: 1
 64:  3: 		<member name="vertices" type="PackedVector2Array" setter="set_vertices" getter="get_vertices" default="PackedVector2Array()">
doc/classes/NavigationObstacle3D.xml: 1
 71:  3: 		<member name="vertices" type="PackedVector3Array" setter="set_vertices" getter="get_vertices" default="PackedVector3Array()">
doc/classes/NavigationPathQueryResult2D.xml: 4
 21:  3: 		<member name="path" type="PackedVector2Array" setter="set_path" getter="get_path" default="PackedVector2Array()">
 24:  3: 		<member name="path_owner_ids" type="PackedInt64Array" setter="set_path_owner_ids" getter="get_path_owner_ids" default="PackedInt64Array()">
 27:  3: 		<member name="path_rids" type="RID[]" setter="set_path_rids" getter="get_path_rids" default="[]">
 30:  3: 		<member name="path_types" type="PackedInt32Array" setter="set_path_types" getter="get_path_types" default="PackedInt32Array()">
doc/classes/NavigationPathQueryResult3D.xml: 4
 21:  3: 		<member name="path" type="PackedVector3Array" setter="set_path" getter="get_path" default="PackedVector3Array()">
 24:  3: 		<member name="path_owner_ids" type="PackedInt64Array" setter="set_path_owner_ids" getter="get_path_owner_ids" default="PackedInt64Array()">
 27:  3: 		<member name="path_rids" type="RID[]" setter="set_path_rids" getter="get_path_rids" default="[]">
 30:  3: 		<member name="path_types" type="PackedInt32Array" setter="set_path_types" getter="get_path_types" default="PackedInt32Array()">
doc/classes/OccluderPolygon2D.xml: 1
 18:  3: 		<member name="polygon" type="PackedVector2Array" setter="set_polygon" getter="get_polygon" default="PackedVector2Array()">
doc/classes/PackedScene.xml: 1
107:  3: 		<member name="_bundled" type="Dictionary" setter="_set_bundled_scene" getter="_get_bundled_scene" default="{ &quot;conn_count&quot;: 0, &quot;conns&quot;: PackedInt32Array(), &quot;editable_instances&quot;: [], &quot;na
doc/classes/PhysicsPointQueryParameters2D.xml: 1
 25:  3: 		<member name="exclude" type="RID[]" setter="set_exclude" getter="get_exclude" default="[]">
doc/classes/PhysicsPointQueryParameters3D.xml: 1
 21:  3: 		<member name="exclude" type="RID[]" setter="set_exclude" getter="get_exclude" default="[]">
doc/classes/PhysicsRayQueryParameters2D.xml: 1
 37:  3: 		<member name="exclude" type="RID[]" setter="set_exclude" getter="get_exclude" default="[]">
doc/classes/PhysicsRayQueryParameters3D.xml: 1
 37:  3: 		<member name="exclude" type="RID[]" setter="set_exclude" getter="get_exclude" default="[]">
doc/classes/PhysicsShapeQueryParameters2D.xml: 1
 21:  3: 		<member name="exclude" type="RID[]" setter="set_exclude" getter="get_exclude" default="[]">
doc/classes/PhysicsShapeQueryParameters3D.xml: 1
 21:  3: 		<member name="exclude" type="RID[]" setter="set_exclude" getter="get_exclude" default="[]">
doc/classes/PhysicsTestMotionParameters2D.xml: 2
 16:  3: 		<member name="exclude_bodies" type="RID[]" setter="set_exclude_bodies" getter="get_exclude_bodies" default="[]">
 19:  3: 		<member name="exclude_objects" type="int[]" setter="set_exclude_objects" getter="get_exclude_objects" default="[]">
doc/classes/PhysicsTestMotionParameters3D.xml: 2
 16:  3: 		<member name="exclude_bodies" type="RID[]" setter="set_exclude_bodies" getter="get_exclude_bodies" default="[]">
 19:  3: 		<member name="exclude_objects" type="int[]" setter="set_exclude_objects" getter="get_exclude_objects" default="[]">
doc/classes/Polygon2D.xml: 5
 74:  3: 		<member name="bones" type="Array" setter="_set_bones" getter="_get_bones" default="[]">
 92:  3: 		<member name="polygon" type="PackedVector2Array" setter="set_polygon" getter="get_polygon" default="PackedVector2Array()">
 96:  3: 		<member name="polygons" type="Array" setter="set_polygons" getter="get_polygons" default="[]">
114:  3: 		<member name="uv" type="PackedVector2Array" setter="set_uv" getter="get_uv" default="PackedVector2Array()">
117:  3: 		<member name="vertex_colors" type="PackedColorArray" setter="set_vertex_colors" getter="get_vertex_colors" default="PackedColorArray()">
doc/classes/PolygonOccluder3D.xml: 1
 14:  3: 		<member name="polygon" type="PackedVector2Array" setter="set_polygon" getter="get_polygon" default="PackedVector2Array()">
doc/classes/PortableCompressedTexture2D.xml: 1
 55:  3: 		<member name="_data" type="PackedByteArray" setter="_set_data" getter="_get_data" default="PackedByteArray()">
doc/classes/ProjectSettings.xml: 78
280:  3: 		<member name="application/config/name_localized" type="Dictionary" setter="" getter="" default="{}">
904:  3: 		<member name="editor/script/search_in_file_extensions" type="PackedStringArray" setter="" getter="" default="PackedStringArray(&quot;gd&quot;, &quot;gdshader&quot;)">
996:  3: 		<member name="input/ui_accept" type="Dictionary" setter="" getter="">
1000:  3: 		<member name="input/ui_cancel" type="Dictionary" setter="" getter="">
1004:  3: 		<member name="input/ui_copy" type="Dictionary" setter="" getter="">
1008:  3: 		<member name="input/ui_cut" type="Dictionary" setter="" getter="">
1012:  3: 		<member name="input/ui_down" type="Dictionary" setter="" getter="">
1016:  3: 		<member name="input/ui_end" type="Dictionary" setter="" getter="">
1020:  3: 		<member name="input/ui_filedialog_refresh" type="Dictionary" setter="" getter="">
1024:  3: 		<member name="input/ui_filedialog_show_hidden" type="Dictionary" setter="" getter="">
1028:  3: 		<member name="input/ui_filedialog_up_one_level" type="Dictionary" setter="" getter="">
1032:  3: 		<member name="input/ui_focus_next" type="Dictionary" setter="" getter="">
1036:  3: 		<member name="input/ui_focus_prev" type="Dictionary" setter="" getter="">
1040:  3: 		<member name="input/ui_graph_delete" type="Dictionary" setter="" getter="">
1044:  3: 		<member name="input/ui_graph_duplicate" type="Dictionary" setter="" getter="">
1048:  3: 		<member name="input/ui_home" type="Dictionary" setter="" getter="">
1052:  3: 		<member name="input/ui_left" type="Dictionary" setter="" getter="">
1056:  3: 		<member name="input/ui_menu" type="Dictionary" setter="" getter="">
1060:  3: 		<member name="input/ui_page_down" type="Dictionary" setter="" getter="">
1064:  3: 		<member name="input/ui_page_up" type="Dictionary" setter="" getter="">
1068:  3: 		<member name="input/ui_paste" type="Dictionary" setter="" getter="">
1072:  3: 		<member name="input/ui_redo" type="Dictionary" setter="" getter="">
1076:  3: 		<member name="input/ui_right" type="Dictionary" setter="" getter="">
1080:  3: 		<member name="input/ui_select" type="Dictionary" setter="" getter="">
1084:  3: 		<member name="input/ui_swap_input_direction" type="Dictionary" setter="" getter="">
1087:  3: 		<member name="input/ui_text_add_selection_for_next_occurrence" type="Dictionary" setter="" getter="">
1094:  3: 		<member name="input/ui_text_backspace" type="Dictionary" setter="" getter="">
1098:  3: 		<member name="input/ui_text_backspace_all_to_left" type="Dictionary" setter="" getter="">
1102:  3: 		<member name="input/ui_text_backspace_all_to_left.macos" type="Dictionary" setter="" getter="">
1105:  3: 		<member name="input/ui_text_backspace_word" type="Dictionary" setter="" getter="">
1109:  3: 		<member name="input/ui_text_backspace_word.macos" type="Dictionary" setter="" getter="">
1112:  3: 		<member name="input/ui_text_caret_add_above" type="Dictionary" setter="" getter="">
1115:  3: 		<member name="input/ui_text_caret_add_above.macos" type="Dictionary" setter="" getter="">
1118:  3: 		<member name="input/ui_text_caret_add_below" type="Dictionary" setter="" getter="">
1121:  3: 		<member name="input/ui_text_caret_add_below.macos" type="Dictionary" setter="" getter="">
1124:  3: 		<member name="input/ui_text_caret_document_end" type="Dictionary" setter="" getter="">
1128:  3: 		<member name="input/ui_text_caret_document_end.macos" type="Dictionary" setter="" getter="">
1131:  3: 		<member name="input/ui_text_caret_document_start" type="Dictionary" setter="" getter="">
1135:  3: 		<member name="input/ui_text_caret_document_start.macos" type="Dictionary" setter="" getter="">
1138:  3: 		<member name="input/ui_text_caret_down" type="Dictionary" setter="" getter="">
1142:  3: 		<member name="input/ui_text_caret_left" type="Dictionary" setter="" getter="">
1146:  3: 		<member name="input/ui_text_caret_line_end" type="Dictionary" setter="" getter="">
1150:  3: 		<member name="input/ui_text_caret_line_end.macos" type="Dictionary" setter="" getter="">
1153:  3: 		<member name="input/ui_text_caret_line_start" type="Dictionary" setter="" getter="">
1157:  3: 		<member name="input/ui_text_caret_line_start.macos" type="Dictionary" setter="" getter="">
1160:  3: 		<member name="input/ui_text_caret_page_down" type="Dictionary" setter="" getter="">
1164:  3: 		<member name="input/ui_text_caret_page_up" type="Dictionary" setter="" getter="">
1168:  3: 		<member name="input/ui_text_caret_right" type="Dictionary" setter="" getter="">
1172:  3: 		<member name="input/ui_text_caret_up" type="Dictionary" setter="" getter="">
1176:  3: 		<member name="input/ui_text_caret_word_left" type="Dictionary" setter="" getter="">
1180:  3: 		<member name="input/ui_text_caret_word_left.macos" type="Dictionary" setter="" getter="">
1183:  3: 		<member name="input/ui_text_caret_word_right" type="Dictionary" setter="" getter="">
1187:  3: 		<member name="input/ui_text_caret_word_right.macos" type="Dictionary" setter="" getter="">
1190:  3: 		<member name="input/ui_text_clear_carets_and_selection" type="Dictionary" setter="" getter="">
1195:  3: 		<member name="input/ui_text_completion_accept" type="Dictionary" setter="" getter="">
1199:  3: 		<member name="input/ui_text_completion_query" type="Dictionary" setter="" getter="">
1203:  3: 		<member name="input/ui_text_completion_replace" type="Dictionary" setter="" getter="">
1207:  3: 		<member name="input/ui_text_dedent" type="Dictionary" setter="" getter="">
1211:  3: 		<member name="input/ui_text_delete" type="Dictionary" setter="" getter="">
1215:  3: 		<member name="input/ui_text_delete_all_to_right" type="Dictionary" setter="" getter="">
1219:  3: 		<member name="input/ui_text_delete_all_to_right.macos" type="Dictionary" setter="" getter="">
1222:  3: 		<member name="input/ui_text_delete_word" type="Dictionary" setter="" getter="">
1226:  3: 		<member name="input/ui_text_delete_word.macos" type="Dictionary" setter="" getter="">
1229:  3: 		<member name="input/ui_text_indent" type="Dictionary" setter="" getter="">
1233:  3: 		<member name="input/ui_text_newline" type="Dictionary" setter="" getter="">
1237:  3: 		<member name="input/ui_text_newline_above" type="Dictionary" setter="" getter="">
1241:  3: 		<member name="input/ui_text_newline_blank" type="Dictionary" setter="" getter="">
1245:  3: 		<member name="input/ui_text_scroll_down" type="Dictionary" setter="" getter="">
1249:  3: 		<member name="input/ui_text_scroll_down.macos" type="Dictionary" setter="" getter="">
1252:  3: 		<member name="input/ui_text_scroll_up" type="Dictionary" setter="" getter="">
1256:  3: 		<member name="input/ui_text_scroll_up.macos" type="Dictionary" setter="" getter="">
1259:  3: 		<member name="input/ui_text_select_all" type="Dictionary" setter="" getter="">
1263:  3: 		<member name="input/ui_text_select_word_under_caret" type="Dictionary" setter="" getter="">
1267:  3: 		<member name="input/ui_text_select_word_under_caret.macos" type="Dictionary" setter="" getter="">
1270:  3: 		<member name="input/ui_text_submit" type="Dictionary" setter="" getter="">
1274:  3: 		<member name="input/ui_text_toggle_insert_mode" type="Dictionary" setter="" getter="">
1278:  3: 		<member name="input/ui_undo" type="Dictionary" setter="" getter="">
1282:  3: 		<member name="input/ui_up" type="Dictionary" setter="" getter="">
doc/classes/RDFramebufferPass.xml: 4
 14:  3: 		<member name="color_attachments" type="PackedInt32Array" setter="set_color_attachments" getter="get_color_attachments" default="PackedInt32Array()">
 20:  3: 		<member name="input_attachments" type="PackedInt32Array" setter="set_input_attachments" getter="get_input_attachments" default="PackedInt32Array()">
 23:  3: 		<member name="preserve_attachments" type="PackedInt32Array" setter="set_preserve_attachments" getter="get_preserve_attachments" default="PackedInt32Array()">
 26:  3: 		<member name="resolve_attachments" type="PackedInt32Array" setter="set_resolve_attachments" getter="get_resolve_attachments" default="PackedInt32Array()">
doc/classes/RDPipelineColorBlendState.xml: 1
 12:  3: 		<member name="attachments" type="RDPipelineColorBlendStateAttachment[]" setter="set_attachments" getter="get_attachments" default="[]">
doc/classes/RDPipelineMultisampleState.xml: 1
 27:  3: 		<member name="sample_masks" type="int[]" setter="set_sample_masks" getter="get_sample_masks" default="[]">
doc/classes/RDShaderSPIRV.xml: 5
 45:  3: 		<member name="bytecode_compute" type="PackedByteArray" setter="set_stage_bytecode" getter="get_stage_bytecode" default="PackedByteArray()">
 48:  3: 		<member name="bytecode_fragment" type="PackedByteArray" setter="set_stage_bytecode" getter="get_stage_bytecode" default="PackedByteArray()">
 51:  3: 		<member name="bytecode_tesselation_control" type="PackedByteArray" setter="set_stage_bytecode" getter="get_stage_bytecode" default="PackedByteArray()">
 54:  3: 		<member name="bytecode_tesselation_evaluation" type="PackedByteArray" setter="set_stage_bytecode" getter="get_stage_bytecode" default="PackedByteArray()">
 57:  3: 		<member name="bytecode_vertex" type="PackedByteArray" setter="set_stage_bytecode" getter="get_stage_bytecode" default="PackedByteArray()">
doc/classes/ResourceImporterBMFont.xml: 1
 18:  3: 		<member name="fallbacks" type="Array" setter="" getter="" default="[]">
doc/classes/ResourceImporterDynamicFont.xml: 5
 28:  3: 		<member name="fallbacks" type="Array" setter="" getter="" default="[]">
 44:  3: 		<member name="language_support" type="Dictionary" setter="" getter="" default="{}">
 57:  3: 		<member name="opentype_features" type="Dictionary" setter="" getter="" default="{}">
 63:  3: 		<member name="preload" type="Array" setter="" getter="" default="[]">
 66:  3: 		<member name="script_support" type="Dictionary" setter="" getter="" default="{}">
doc/classes/ResourceImporterImageFont.xml: 2
 17:  3: 		<member name="character_ranges" type="PackedStringArray" setter="" getter="" default="PackedStringArray()">
 28:  3: 		<member name="fallbacks" type="Array" setter="" getter="" default="[]">
doc/classes/ResourceImporterScene.xml: 1
 15:  3: 		<member name="_subresources" type="Dictionary" setter="" getter="" default="{}">
doc/classes/RichTextLabel.xml: 2
554:  3: 		<member name="custom_effects" type="Array" setter="set_effects" getter="get_effects" default="[]">
595:  3: 		<member name="structured_text_bidi_override_options" type="Array" setter="set_structured_text_bidi_override_options" getter="get_structured_text_bidi_override_options" default="[]">
doc/classes/ShapeCast2D.xml: 1
141:  3: 		<member name="collision_result" type="Array" setter="" getter="_get_collision_result" default="[]">
doc/classes/ShapeCast3D.xml: 1
148:  3: 		<member name="collision_result" type="Array" setter="" getter="_get_collision_result" default="[]">
doc/classes/Shortcut.xml: 1
 34:  3: 		<member name="events" type="Array" setter="set_events" getter="get_events" default="[]">
doc/classes/StreamPeerBuffer.xml: 1
 53:  3: 		<member name="data_array" type="PackedByteArray" setter="set_data_array" getter="get_data_array" default="PackedByteArray()">
doc/classes/SystemFont.xml: 1
 25:  3: 		<member name="font_names" type="PackedStringArray" setter="set_font_names" getter="get_font_names" default="PackedStringArray()">
doc/classes/TextEdit.xml: 1
1190:  3: 		<member name="structured_text_bidi_override_options" type="Array" setter="set_structured_text_bidi_override_options" getter="get_structured_text_bidi_override_options" default="[]">
doc/classes/TextMesh.xml: 1
 51:  3: 		<member name="structured_text_bidi_override_options" type="Array" setter="set_structured_text_bidi_override_options" getter="get_structured_text_bidi_override_options" default="[]">
doc/classes/Window.xml: 1
614:  3: 		<member name="mouse_passthrough_polygon" type="PackedVector2Array" setter="set_mouse_passthrough_polygon" getter="get_mouse_passthrough_polygon" default="PackedVector2Array()">
modules/csg/doc_classes/CSGPolygon3D.xml: 1
 50:  3: 		<member name="polygon" type="PackedVector2Array" setter="set_polygon" getter="get_polygon" default="PackedVector2Array(0, 0, 0, 1, 1, 1, 1, 0)">
modules/gltf/doc_classes/GLTFAccessor.xml: 2
 18:  3: 		<member name="max" type="PackedFloat64Array" setter="set_max" getter="get_max" default="PackedFloat64Array()">
 20:  3: 		<member name="min" type="PackedFloat64Array" setter="set_min" getter="get_min" default="PackedFloat64Array()">
modules/gltf/doc_classes/GLTFMesh.xml: 2
 10:  3: 		<member name="blend_weights" type="PackedFloat32Array" setter="set_blend_weights" getter="get_blend_weights" default="PackedFloat32Array()">
 12:  3: 		<member name="instance_materials" type="Material[]" setter="set_instance_materials" getter="get_instance_materials" default="[]">
modules/gltf/doc_classes/GLTFNode.xml: 1
 36:  3: 		<member name="children" type="PackedInt32Array" setter="set_children" getter="get_children" default="PackedInt32Array()">
modules/gltf/doc_classes/GLTFSkeleton.xml: 2
 52:  3: 		<member name="joints" type="PackedInt32Array" setter="set_joints" getter="get_joints" default="PackedInt32Array()">
 54:  3: 		<member name="roots" type="PackedInt32Array" setter="set_roots" getter="get_roots" default="PackedInt32Array()">
modules/gltf/doc_classes/GLTFSkin.xml: 4
 47:  3: 		<member name="joints" type="PackedInt32Array" setter="set_joints" getter="get_joints" default="PackedInt32Array()">
 49:  3: 		<member name="joints_original" type="PackedInt32Array" setter="set_joints_original" getter="get_joints_original" default="PackedInt32Array()">
 51:  3: 		<member name="non_joints" type="PackedInt32Array" setter="set_non_joints" getter="get_non_joints" default="PackedInt32Array()">
 53:  3: 		<member name="roots" type="PackedInt32Array" setter="set_roots" getter="get_roots" default="PackedInt32Array()">
modules/gltf/doc_classes/GLTFState.xml: 4
272:  3: 		<member name="buffers" type="PackedByteArray[]" setter="set_buffers" getter="get_buffers" default="[]">
282:  3: 		<member name="glb_data" type="PackedByteArray" setter="set_glb_data" getter="get_glb_data" default="PackedByteArray()">
284:  3: 		<member name="json" type="Dictionary" setter="set_json" getter="get_json" default="{}">
290:  3: 		<member name="root_nodes" type="PackedInt32Array" setter="set_root_nodes" getter="get_root_nodes" default="PackedInt32Array()">
modules/minimp3/doc_classes/AudioStreamMP3.xml: 1
 18:  3: 		<member name="data" type="PackedByteArray" setter="set_data" getter="get_data" default="PackedByteArray()">
modules/ogg/doc_classes/OggPacketSequence.xml: 2
 20:  3: 		<member name="granule_positions" type="PackedInt64Array" setter="set_packet_granule_positions" getter="get_packet_granule_positions" default="PackedInt64Array()">
 23:  3: 		<member name="packet_data" type="Array[]" setter="set_packet_data" getter="get_packet_data" default="[]">
modules/openxr/doc_classes/OpenXRAction.xml: 1
 21:  3: 		<member name="toplevel_paths" type="PackedStringArray" setter="set_toplevel_paths" getter="get_toplevel_paths" default="PackedStringArray()">
modules/openxr/doc_classes/OpenXRActionMap.xml: 2
 90:  3: 		<member name="action_sets" type="Array" setter="set_action_sets" getter="get_action_sets" default="[]">
 93:  3: 		<member name="interaction_profiles" type="Array" setter="set_interaction_profiles" getter="get_interaction_profiles" default="[]">
modules/openxr/doc_classes/OpenXRActionSet.xml: 1
 35:  3: 		<member name="actions" type="Array" setter="set_actions" getter="get_actions" default="[]">
modules/openxr/doc_classes/OpenXRIPBinding.xml: 1
 44:  3: 		<member name="paths" type="PackedStringArray" setter="set_paths" getter="get_paths" default="PackedStringArray()">
modules/openxr/doc_classes/OpenXRInteractionProfile.xml: 1
 28:  3: 		<member name="bindings" type="Array" setter="set_bindings" getter="get_bindings" default="[]">
modules/regex/doc_classes/RegExMatch.xml: 2
 44:  3: 		<member name="names" type="Dictionary" setter="" getter="get_names" default="{}">
 47:  3: 		<member name="strings" type="PackedStringArray" setter="" getter="get_strings" default="PackedStringArray()">
modules/websocket/doc_classes/WebSocketMultiplayerPeer.xml: 2
 54:  3: 		<member name="handshake_headers" type="PackedStringArray" setter="set_handshake_headers" getter="get_handshake_headers" default="PackedStringArray()">
 69:  3: 		<member name="supported_protocols" type="PackedStringArray" setter="set_supported_protocols" getter="get_supported_protocols" default="PackedStringArray()">
modules/websocket/doc_classes/WebSocketPeer.xml: 2
154:  3: 		<member name="handshake_headers" type="PackedStringArray" setter="set_handshake_headers" getter="get_handshake_headers" default="PackedStringArray()">
167:  3: 		<member name="supported_protocols" type="PackedStringArray" setter="set_supported_protocols" getter="get_supported_protocols" default="PackedStringArray()">
platform/android/doc_classes/EditorExportPlatformAndroid.xml: 1
259:  3: 		<member name="permissions/custom_permissions" type="PackedStringArray" setter="" getter="">
platform/ios/doc_classes/EditorExportPlatformIOS.xml: 3
147:  3: 		<member name="privacy/camera_usage_description_localized" type="Dictionary" setter="" getter="">
153:  3: 		<member name="privacy/microphone_usage_description_localized" type="Dictionary" setter="" getter="">
159:  3: 		<member name="privacy/photolibrary_usage_description_localized" type="Dictionary" setter="" getter="">
platform/macos/doc_classes/EditorExportPlatformMacOS.xml: 14
 22:  3: 		<member name="application/copyright_localized" type="Dictionary" setter="" getter="">
 62:  3: 		<member name="codesign/custom_options" type="PackedStringArray" setter="" getter="">
102:  3: 		<member name="codesign/entitlements/app_sandbox/helper_executables" type="Array" setter="" getter="">
189:  3: 		<member name="privacy/address_book_usage_description_localized" type="Dictionary" setter="" getter="">
195:  3: 		<member name="privacy/calendar_usage_description_localized" type="Dictionary" setter="" getter="">
201:  3: 		<member name="privacy/camera_usage_description_localized" type="Dictionary" setter="" getter="">
207:  3: 		<member name="privacy/desktop_folder_usage_description_localized" type="Dictionary" setter="" getter="">
213:  3: 		<member name="privacy/documents_folder_usage_description_localized" type="Dictionary" setter="" getter="">
219:  3: 		<member name="privacy/downloads_folder_usage_description_localized" type="Dictionary" setter="" getter="">
225:  3: 		<member name="privacy/location_usage_description_localized" type="Dictionary" setter="" getter="">
231:  3: 		<member name="privacy/microphone_usage_description_localized" type="Dictionary" setter="" getter="">
237:  3: 		<member name="privacy/network_volumes_usage_description_localized" type="Dictionary" setter="" getter="">
243:  3: 		<member name="privacy/photos_library_usage_description_localized" type="Dictionary" setter="" getter="">
249:  3: 		<member name="privacy/removable_volumes_usage_description_localized" type="Dictionary" setter="" getter="">
platform/windows/doc_classes/EditorExportPlatformWindows.xml: 1
 53:  3: 		<member name="codesign/custom_options" type="PackedStringArray" setter="" getter="">

@AThousandShips
Copy link
Member

Should probably be documented on each of the packed types as well

@OffsetMOSFET
Copy link
Author

Thank you for the clear explanation.

@OffsetMOSFET
Copy link
Author

Seeing that the API for stable has been updated to note that the arrays are copies, I will close this.

@dalexeev dalexeev added this to the 4.3 milestone Aug 16, 2024
@dalexeev
Copy link
Member

However, this note is missing for arrays and dictionaries. Also, there are some exceptions where built-in pass-by-reference properties takes modification into account, but this is difficult to detect automatically. CC @AThousandShips

@AThousandShips
Copy link
Member

Arrays and dictionaries are a case by case thing as some are passed directly and some are copied, so some manual thing would need to be added

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants