Skip to content

Fix stop-when last-picture display regression - #270

Open
brysenPfingsten wants to merge 1 commit into
racket:masterfrom
brysenPfingsten:fix/stop-when-last-picture
Open

brysenPfingsten wants to merge 1 commit into
racket:masterfrom
brysenPfingsten:fix/stop-when-last-picture

Conversation

@brysenPfingsten

Copy link
Copy Markdown

Commit f40c4a1 changed close-on-stop's default from #false to #true to avoid blocking the evaluator after big-bang returns. It introduced a regression in the two-argument form of stop-when. When last-picture is provided, wrap-up now takes the else branch, which immediately calls (send the-frame show #f) with no prior yield. The event loop never gets a chance to repaint the canvas, so the window closes and the final scene never appears.

The fix I'm suggesting is to tidy up the cond and call (sleep/yield 600) before hiding the frame. This is what was happening in the (close-on-stop #false) case.

Example that now works as expected:

(big-bang 5
  [on-tick sub1 1]
  [to-draw  (lambda (w) (square 500 'solid 'green))]
  [stop-when zero? (lambda (w) (square 500 'solid 'red))])

Commit f40c4a1 changed close-on-stop's default from #false to #true to
avoid blocking the evaluator after big-bang returns. It introduced a
regression in the two-argument form of stop-when. When last-picture is
provided, wrap-up now takes the else branch, which immediately calls
(send the-frame show #f) with no prior yield. The event loop never gets
a chance to repaint the canvas, so the window closes and the final scene
never appears.

The fix I'm suggesting is to tidy up the cond and call (sleep/yield 600)
before hiding the frame. This is what was happening in the
(close-on-stop #false) case.

Example that now works as expected:

(big-bang 5
  [on-tick sub1 1]
  [to-draw  (lambda (w) (square 500 'solid 'green))]
  [stop-when zero? (lambda (w) (square 500 'solid 'red))])
@shhyou shhyou added bug teachpack [2]htdp teachpack labels Oct 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug teachpack [2]htdp teachpack

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants