Skip to content

Commit 09b4926

Browse files
committed
fix: prevent race condition when switching levels
Added a check that does not restart the preview if it detects that the user switched levels during the pause period.
1 parent ec45a00 commit 09b4926

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

scripts/levels.gd

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ func _on_Button_focus_entered(size=_level.array.size):
6969
set_process_input(false)
7070
$Timer.stop()
7171
yield(get_tree().create_timer(1), "timeout")
72+
if not _level.array.is_sorted():
73+
return
7274
$Timer.start()
7375
set_process_input(true)
7476
_level = _get_level(get_focus_owner().text).new(ArrayModel.new(size))

0 commit comments

Comments
 (0)