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
+29
-6
@@ -4,6 +4,7 @@ extends SceneTree
|
||||
## <godot> --headless --path . --script res://tools/ui_test.gd
|
||||
|
||||
var failures := 0
|
||||
var frames = null
|
||||
|
||||
|
||||
func _init() -> void:
|
||||
@@ -33,6 +34,13 @@ func _run() -> void:
|
||||
quit(1)
|
||||
return
|
||||
|
||||
# Resolve at runtime so Frames.gd does not compile before autoloads exist.
|
||||
frames = load("res://scripts/Frames.gd")
|
||||
_check(frames != null, "Frames script missing")
|
||||
if frames == null:
|
||||
quit(1)
|
||||
return
|
||||
|
||||
_test_save_defaults(save)
|
||||
save.reset_progress()
|
||||
await _test_daily_and_frames(save, main)
|
||||
@@ -141,18 +149,18 @@ func _test_daily_and_frames(save, main) -> void:
|
||||
save.save_game()
|
||||
|
||||
save.reset_progress()
|
||||
_check(Frames.is_unlocked("plain"), "plain frame should always be available")
|
||||
_check(not Frames.is_unlocked("paper"), "Paper should need rooms")
|
||||
_check(frames.is_unlocked("plain"), "plain frame should always be available")
|
||||
_check(not frames.is_unlocked("paper"), "Paper should need rooms")
|
||||
for i in range(5):
|
||||
save.data["completed_rooms"].append("room-%02d" % i)
|
||||
save.save_game()
|
||||
_check(Frames.is_unlocked("paper"), "five rooms should unlock Paper")
|
||||
_check(not Frames.is_unlocked("bell"), "Bellhop should still be locked")
|
||||
_check(frames.is_unlocked("paper"), "five rooms should unlock Paper")
|
||||
_check(not frames.is_unlocked("bell"), "Bellhop should still be locked")
|
||||
var stats: Dictionary = save.daily_data()
|
||||
stats["best_streak"] = 3
|
||||
save.data["daily"] = stats
|
||||
save.save_game()
|
||||
_check(Frames.is_unlocked("regular"), "a 3-day best streak should unlock Regular")
|
||||
_check(frames.is_unlocked("regular"), "a 3-day best streak should unlock Regular")
|
||||
save.select_frame("regular")
|
||||
save.load_game()
|
||||
_check(save.selected_frame() == "regular", "frame selection should persist")
|
||||
@@ -162,13 +170,28 @@ func _test_daily_and_frames(save, main) -> void:
|
||||
_check(main.profile != null, "Profile screen missing")
|
||||
if main.profile != null:
|
||||
_check(
|
||||
main.profile.frame_grid.get_child_count() == Frames.all().size(),
|
||||
main.profile.frame_grid.get_child_count() == frames.all().size(),
|
||||
"Profile should show every frame"
|
||||
)
|
||||
_check(
|
||||
main.profile.frame_grid.get_child(0).mouse_filter == Control.MOUSE_FILTER_PASS,
|
||||
"frame cards should pass swipes"
|
||||
)
|
||||
# Regression: pressing a card must not free that card while its
|
||||
# `pressed` signal is still on the stack.
|
||||
var regular_index := -1
|
||||
for i in frames.all().size():
|
||||
if str(frames.all()[i].get("id", "")) == "regular":
|
||||
regular_index = i
|
||||
if regular_index >= 0:
|
||||
main.profile.frame_grid.get_child(regular_index).pressed.emit()
|
||||
await process_frame
|
||||
await process_frame
|
||||
_check(save.selected_frame() == "regular", "frame press should select the frame")
|
||||
_check(
|
||||
main.profile.frame_grid.get_child_count() == frames.all().size(),
|
||||
"frame grid should stay stable after selection"
|
||||
)
|
||||
main.show_screen("home")
|
||||
main.home.daily_pressed.emit()
|
||||
await process_frame
|
||||
|
||||
Reference in new issue
Block a user