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:
1 parent
3c2ead0be1
commit
48c14864a4
5 files changed
+41
-12
No files matched your search
+8
-2
@@ -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)
|
||||
|
||||
Reference in new issue
Block a user