From 259e466f26c7d1af21e2a90e95ae5431ecaf125b Mon Sep 17 00:00:00 2001 From: betalars Date: Wed, 3 Jun 2026 14:40:20 +0200 Subject: [PATCH] fix minor memory leak from cards being removed instead of freed --- src/logic-scenes/card_picker/card_picker.gd | 5 +- src/logic-scenes/card_picker/card_picker.tscn | 96 ++++++++----------- 2 files changed, 44 insertions(+), 57 deletions(-) diff --git a/src/logic-scenes/card_picker/card_picker.gd b/src/logic-scenes/card_picker/card_picker.gd index 5b11ba95..06932379 100644 --- a/src/logic-scenes/card_picker/card_picker.gd +++ b/src/logic-scenes/card_picker/card_picker.gd @@ -67,7 +67,7 @@ func fill_card_slots(id: int): var new_cards : Array[Card] = CardLibrary.get_cards_by_scene_id(id) for i in range(new_cards.size()): - $cards.get_child(i).remove_child($cards.get_child(i).get_child(1)) + $cards.get_child(i).get_child(1).free() var new_card:Card = new_cards[i] $cards.get_child(i).add_child(new_card) #new_card.owner = self @@ -76,6 +76,7 @@ func fill_card_slots(id: int): options.append(new_card) anim_players.append($cards.get_child(i).get_child(0)) + func fill_post_slots(): var sticky_notes: Array[StickyNote] = [] for card: Card in output: @@ -87,7 +88,7 @@ func fill_post_slots(): sticky_notes.shuffle() options = [] for ancor in $sticky_notes.get_children(): - ancor.remove_child(ancor.get_child(1)) + ancor.get_child(1).queue_free() for i in range(sticky_notes.size()): options.append(sticky_notes[i]) diff --git a/src/logic-scenes/card_picker/card_picker.tscn b/src/logic-scenes/card_picker/card_picker.tscn index 6331ada4..1f3eb3e8 100644 --- a/src/logic-scenes/card_picker/card_picker.tscn +++ b/src/logic-scenes/card_picker/card_picker.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=73 format=3 uid="uid://brk4hjdf2x81a"] +[gd_scene format=3 uid="uid://brk4hjdf2x81a"] [ext_resource type="Script" uid="uid://bdb6n10apk1en" path="res://logic-scenes/card_picker/card_picker.gd" id="1_pjntm"] [ext_resource type="PackedScene" uid="uid://dy5rd437h5hsw" path="res://logic-scenes/board/card.tscn" id="2_t7byf"] @@ -1735,7 +1735,7 @@ _data = { &"unshuffle": SubResource("Animation_hh1hx") } -[node name="picker" type="CenterContainer"] +[node name="picker" type="CenterContainer" unique_id=862619462] anchors_preset = 15 anchor_right = 1.0 anchor_bottom = 1.0 @@ -1743,10 +1743,10 @@ grow_horizontal = 2 grow_vertical = 2 script = ExtResource("1_pjntm") -[node name="Control" type="Control" parent="."] +[node name="Control" type="Control" parent="." unique_id=2037101189] layout_mode = 2 -[node name="label" type="Label" parent="Control"] +[node name="label" type="Label" parent="Control" unique_id=85052670] layout_mode = 0 offset_left = -359.0 offset_top = -256.0 @@ -1755,11 +1755,11 @@ offset_bottom = -218.0 text = "Pick a Card to take with you, a second one will be randomly assigned." horizontal_alignment = 1 -[node name="cards" type="Panel" parent="."] +[node name="cards" type="Panel" parent="." unique_id=1391420795] layout_mode = 2 mouse_filter = 2 -[node name="card_1" type="Control" parent="cards"] +[node name="card_1" type="Control" parent="cards" unique_id=1760536334] anchors_preset = 0 offset_left = -317.0 offset_top = 25.0 @@ -1768,25 +1768,21 @@ offset_bottom = 25.0 rotation = -0.109599 mouse_filter = 1 -[node name="AnimationPlayer" type="AnimationPlayer" parent="cards/card_1"] -libraries = { -&"": SubResource("AnimationLibrary_gdxmh") -} +[node name="AnimationPlayer" type="AnimationPlayer" parent="cards/card_1" unique_id=11133187] +libraries/ = SubResource("AnimationLibrary_gdxmh") -[node name="Card" parent="cards/card_1" instance=ExtResource("2_t7byf")] +[node name="Card" parent="cards/card_1" unique_id=634126263 instance=ExtResource("2_t7byf")] -[node name="card_2" type="Control" parent="cards"] +[node name="card_2" type="Control" parent="cards" unique_id=2133380151] anchors_preset = 0 mouse_filter = 2 -[node name="AnimationPlayer" type="AnimationPlayer" parent="cards/card_2"] -libraries = { -&"": SubResource("AnimationLibrary_oxheu") -} +[node name="AnimationPlayer" type="AnimationPlayer" parent="cards/card_2" unique_id=884409750] +libraries/ = SubResource("AnimationLibrary_oxheu") -[node name="Card" parent="cards/card_2" instance=ExtResource("2_t7byf")] +[node name="Card" parent="cards/card_2" unique_id=544537009 instance=ExtResource("2_t7byf")] -[node name="card_3" type="Control" parent="cards"] +[node name="card_3" type="Control" parent="cards" unique_id=1904350726] anchors_preset = 0 offset_left = 315.0 offset_top = 22.0 @@ -1794,82 +1790,72 @@ offset_right = 315.0 offset_bottom = 22.0 rotation = 0.10472 -[node name="AnimationPlayer" type="AnimationPlayer" parent="cards/card_3"] -libraries = { -&"": SubResource("AnimationLibrary_8blxm") -} +[node name="AnimationPlayer" type="AnimationPlayer" parent="cards/card_3" unique_id=524877968] +libraries/ = SubResource("AnimationLibrary_8blxm") -[node name="Card" parent="cards/card_3" instance=ExtResource("2_t7byf")] +[node name="Card" parent="cards/card_3" unique_id=2060626063 instance=ExtResource("2_t7byf")] -[node name="sticky_notes" type="Panel" parent="."] +[node name="sticky_notes" type="Panel" parent="." unique_id=1381586432] layout_mode = 2 mouse_filter = 2 -[node name="sticky_note_1" type="Control" parent="sticky_notes"] +[node name="sticky_note_1" type="Control" parent="sticky_notes" unique_id=588979489] anchors_preset = 0 offset_top = -150.0 offset_bottom = -150.0 mouse_filter = 2 -[node name="AnimationPlayer" type="AnimationPlayer" parent="sticky_notes/sticky_note_1"] +[node name="AnimationPlayer" type="AnimationPlayer" parent="sticky_notes/sticky_note_1" unique_id=309801820] root_node = NodePath(".") -libraries = { -&"": SubResource("AnimationLibrary_ga4dm") -} -autoplay = "ini" +libraries/ = SubResource("AnimationLibrary_ga4dm") +autoplay = &"ini" -[node name="sticky-note" parent="sticky_notes/sticky_note_1" instance=ExtResource("3_et74x")] +[node name="sticky-note" parent="sticky_notes/sticky_note_1" unique_id=1215632612 instance=ExtResource("3_et74x")] -[node name="sticky_note_2" type="Control" parent="sticky_notes"] +[node name="sticky_note_2" type="Control" parent="sticky_notes" unique_id=539498438] anchors_preset = 0 offset_top = -50.0 offset_bottom = -50.0 mouse_filter = 2 -[node name="AnimationPlayer" type="AnimationPlayer" parent="sticky_notes/sticky_note_2"] +[node name="AnimationPlayer" type="AnimationPlayer" parent="sticky_notes/sticky_note_2" unique_id=394265426] root_node = NodePath(".") -libraries = { -&"": SubResource("AnimationLibrary_sxnmi") -} -autoplay = "ini" +libraries/ = SubResource("AnimationLibrary_sxnmi") +autoplay = &"ini" -[node name="sticky-note" parent="sticky_notes/sticky_note_2" instance=ExtResource("3_et74x")] +[node name="sticky-note" parent="sticky_notes/sticky_note_2" unique_id=1393845997 instance=ExtResource("3_et74x")] -[node name="sticky_note_3" type="Control" parent="sticky_notes"] +[node name="sticky_note_3" type="Control" parent="sticky_notes" unique_id=1794056835] anchors_preset = 0 offset_top = 50.0 offset_bottom = 50.0 mouse_filter = 2 -[node name="AnimationPlayer" type="AnimationPlayer" parent="sticky_notes/sticky_note_3"] +[node name="AnimationPlayer" type="AnimationPlayer" parent="sticky_notes/sticky_note_3" unique_id=273237816] root_node = NodePath(".") -libraries = { -&"": SubResource("AnimationLibrary_xs06v") -} -autoplay = "ini" +libraries/ = SubResource("AnimationLibrary_xs06v") +autoplay = &"ini" -[node name="sticky-note" parent="sticky_notes/sticky_note_3" instance=ExtResource("3_et74x")] +[node name="sticky-note" parent="sticky_notes/sticky_note_3" unique_id=1878643316 instance=ExtResource("3_et74x")] -[node name="sticky_note_4" type="Control" parent="sticky_notes"] +[node name="sticky_note_4" type="Control" parent="sticky_notes" unique_id=400909666] anchors_preset = 0 offset_top = 150.0 offset_bottom = 150.0 mouse_filter = 2 -[node name="AnimationPlayer" type="AnimationPlayer" parent="sticky_notes/sticky_note_4"] +[node name="AnimationPlayer" type="AnimationPlayer" parent="sticky_notes/sticky_note_4" unique_id=864955044] root_node = NodePath(".") -libraries = { -&"": SubResource("AnimationLibrary_tdl1s") -} -autoplay = "ini" +libraries/ = SubResource("AnimationLibrary_tdl1s") +autoplay = &"ini" -[node name="sticky-note" parent="sticky_notes/sticky_note_4" instance=ExtResource("3_et74x")] +[node name="sticky-note" parent="sticky_notes/sticky_note_4" unique_id=608976287 instance=ExtResource("3_et74x")] -[node name="thought_prompt" type="Control" parent="."] +[node name="thought_prompt" type="Control" parent="." unique_id=309795113] layout_mode = 2 mouse_filter = 2 -[node name="Label" type="Label" parent="thought_prompt"] +[node name="Label" type="Label" parent="thought_prompt" unique_id=2122400212] layout_mode = 1 anchors_preset = 8 anchor_left = 0.5 @@ -1886,7 +1872,7 @@ theme_type_variation = &"HeaderMedium" text = "Why does that story mean so much to me?" horizontal_alignment = 1 -[node name="Meaning" type="AudioStreamPlayer" parent="."] +[node name="Meaning" type="AudioStreamPlayer" parent="." unique_id=289900091] stream = ExtResource("4_ujc5a") mix_target = 2 bus = &"text"