diff --git a/collects/2htdp/private/checked-cell.ss b/collects/2htdp/private/checked-cell.ss index d5fc56f6c1..8136aed963 100644 --- a/collects/2htdp/private/checked-cell.ss +++ b/collects/2htdp/private/checked-cell.ss @@ -73,12 +73,14 @@ ;; effect: set value to v if distinct, also display it if pb exists (define/public (set tag v) (define nw (coerce tag v)) - (if (equal? value nw) - #t - (begin - (set! value nw) - (when pb (show-state)) - #f))) + ;; this is the old Robby "optimization" for not triggering draw + ;; when the world doesn't change + ;if (equal? value nw) + ; #t + (begin + (set! value nw) + (when pb (show-state)) + #f)) ;; -> ok? (define/public (get) value) diff --git a/collects/2htdp/private/universe-image.ss b/collects/2htdp/private/universe-image.ss index 1b614d2afa..34609ab16d 100644 --- a/collects/2htdp/private/universe-image.ss +++ b/collects/2htdp/private/universe-image.ss @@ -58,7 +58,7 @@ i (if (1:image? i) (check-result tname 1:scene? "scene" i (image-pins i)) - (check-result tname #f "scene" i)))) + (check-result tname (lambda _ #f) "scene" i)))) (define (image-pins i) (format "image with pinhole at (~s,~s)" (1:pinhole-x i) (1:pinhole-y i))) diff --git a/collects/2htdp/private/world.ss b/collects/2htdp/private/world.ss index 735fe7b7c9..dfc88bd8f7 100644 --- a/collects/2htdp/private/world.ss +++ b/collects/2htdp/private/world.ss @@ -233,39 +233,40 @@ (broadcast (package-message nw)) (set! nw (package-world nw))) (if (stop-the-world? nw) - (begin - (set! nw (stop-the-world-world nw)) - (send world set tag nw) - (when last-picture - (set! draw last-picture)) - (when draw (pdraw)) - (callback-stop! 'name) - (enable-images-button)) + (begin + (set! nw (stop-the-world-world nw)) + (send world set tag nw) + (when last-picture + (set! draw last-picture)) + (when draw (pdraw)) + (callback-stop! 'name) + (enable-images-button)) (let ([changed-world? (send world set tag nw)]) - (unless changed-world? - (when draw - (cond - [(not drawing) - (set! drawing #t) - (let ([b (box d)]) - (set! w (cons b w)) - ;; low priority, otherwise it's too fast - (queue-callback (lambda () ((unbox b))) #f))] - [(< draw# 0) - (set-draw#!) - (for-each (lambda (b) (set-box! b void)) w) - (set! w '()) - ;; high!! the scheduled callback didn't fire - (queue-callback (lambda () (d)) #t)] - [else - (set! draw# (- draw# 1))])) - (when (pstop) - (when last-picture - (set! draw last-picture) - (pdraw)) - (callback-stop! 'name) - (enable-images-button))) - changed-world?))))))) + ;; this is the old "Robby optimization" see checked-cell: + ; unless changed-world? + (when draw + (cond + [(not drawing) + (set! drawing #t) + (let ([b (box d)]) + (set! w (cons b w)) + ;; low priority, otherwise it's too fast + (queue-callback (lambda () ((unbox b))) #f))] + [(< draw# 0) + (set-draw#!) + (for-each (lambda (b) (set-box! b void)) w) + (set! w '()) + ;; high!! the scheduled callback didn't fire + (queue-callback (lambda () (d)) #t)] + [else + (set! draw# (- draw# 1))])) + (when (pstop) + (when last-picture + (set! draw last-picture) + (pdraw)) + (callback-stop! 'name) + (enable-images-button)) + changed-world?))))))) ;; tick, tock : deal with a tick event for this world (def/pub-cback (ptock) tick) @@ -314,8 +315,9 @@ (define/public (start!) (queue-callback (lambda () - (when draw (show-canvas)) - (when register (register-with-host))))) + (with-handlers ([exn? (handler #t)]) + (when draw (show-canvas)) + (when register (register-with-host)))))) (define/public (stop! w) (set! live #f)