fix(profile): avoid freeing nodes during their own signal

Defer frame selection and use queued deletion when rebuilding frame cards, avatars, Guest Book cards, and legend chips. Adds a regression check that presses a frame card and verifies the grid stays stable.
This commit is contained in:
Ratdoku Builder committed 2026-12-02 22:48:08 -06:00
1 parent 3c2ead0be1
commit 48c14864a4
5 files changed
+41 -12

No files matched your search

+1 -1
View File
@@ -266,7 +266,7 @@ func start_daily(index: int, key: String) -> void:
func _refresh_legend() -> void:
for child in legend_row.get_children():
child.free()
child.queue_free()
legend_chips.clear()
if board.region_rats.is_empty():
return
+2 -2
View File
@@ -99,7 +99,7 @@ func _build_crumb_frame() -> void:
if crumb_frame_id == selected and crumb_frame_holder.get_child_count() > 0:
return
for child in crumb_frame_holder.get_children():
child.free()
child.queue_free()
var frame := Frames.frame_panel(selected, 56)
var portrait := TextureRect.new()
portrait.custom_minimum_size = Vector2(44, 44)
@@ -145,7 +145,7 @@ func refresh() -> void:
return
_build_crumb_frame()
for child in grid.get_children():
child.free()
child.queue_free()
var guests := Guests.all()
var unlocked := SaveGame.unlocked_count(guests)
+1 -1
View File
@@ -166,7 +166,7 @@ func _refresh_avatar() -> void:
if avatar_frame_id == SaveGame.selected_frame():
return
for child in avatar_holder.get_children():
child.free()
child.queue_free()
_build_avatar()
+8 -2
View File
@@ -104,7 +104,7 @@ func _build_portrait() -> void:
if portrait_frame_id == selected and portrait_holder.get_child_count() > 0:
return
for child in portrait_holder.get_children():
child.free()
child.queue_free()
var frame := Frames.frame_panel(selected, 118)
var head := TextureRect.new()
head.texture = load("res://art/crumb_head.png")
@@ -119,7 +119,7 @@ func _build_portrait() -> void:
func _build_frames() -> void:
for child in frame_grid.get_children():
child.free()
child.queue_free()
var selected := SaveGame.selected_frame()
for frame in Frames.all():
@@ -183,6 +183,12 @@ func _on_frame_pressed(id: String, unlocked: bool) -> void:
status_label.text = "Locked: %s." % Frames.requirement_text(id)
status_label.add_theme_color_override("font_color", Palette.RED)
return
# Never rebuild the card grid while the card's own `pressed` signal is
# still on the stack; Godot locks the emitting node during the call.
call_deferred("_apply_frame", id)
func _apply_frame(id: String) -> void:
SaveGame.select_frame(id)
status_label.text = "Now wearing %s." % str(Frames.by_id(id).get("name", id))
status_label.add_theme_color_override("font_color", Palette.MUTED)