diff --git a/collects/2htdp/private/world.ss b/collects/2htdp/private/world.ss index 9b949c1f89..67f90960c9 100644 --- a/collects/2htdp/private/world.ss +++ b/collects/2htdp/private/world.ss @@ -213,7 +213,7 @@ (define/public (name arg ...) (queue-callback (lambda () - (with-handlers ([exn:break? (handler #f)][exn? (handler #t)]) + (with-handlers ([exn? (handler #t)]) (define tag (format "~a callback" 'transform)) (define nw (transform (send world get) arg ...)) (when (package? nw) @@ -266,6 +266,7 @@ (define (handler re-raise) (lambda (e) + (printf "breaking ..\n") (disable-images-button) (stop! (if re-raise e (send world get))))) diff --git a/collects/2htdp/universe.ss b/collects/2htdp/universe.ss index 8650daf7cf..2c1e62050c 100644 --- a/collects/2htdp/universe.ss +++ b/collects/2htdp/universe.ss @@ -41,8 +41,8 @@ [(_ x rate) #'(list (proc> 'on-tick (f2h x) 1) (num> 'on-tick rate (lambda (x) - (and (real? x) (positive? x))) - "pos. number" "rate"))])] + (and (real? x) (positive? x))) + "pos. number" "rate"))])] ;; -- state specifies whether to display the current state [state (expr-with-check bool> "expected a boolean (show state or not)")] ;; -- check-with must specify a predicate @@ -169,9 +169,12 @@ [_ (err '#'record? stx)])))] [args (->args stx (syntax (clause ...)) AllSpec WldSpec ->rec? "world")]) - #`(parameterize ([current-eventspace (make-eventspace)]) - (let ([o (new (if #,rec? aworld% world%) [world0 w] #,@args)]) - (send o last))))])) + #`(let* ([esp (make-eventspace)] + [thd (eventspace-handler-thread esp)]) + (with-handlers ((exn:break? (lambda (x) (break-thread thd)))) + (parameterize ([current-eventspace esp]) + (let ([o (new (if #,rec? aworld% world%) [world0 w] #,@args)]) + (send o last))))))])) (define (run-simulation f) (check-proc 'run-simulation f 1 "first" "one argument") @@ -267,6 +270,9 @@ [(not (memq 'on-msg domain)) (raise-syntax-error #f "missing on-msg clause" stx)] [else ; (and (memq #'on-new domain) (memq #'on-msg domain)) - #`(parameterize ([current-eventspace (make-eventspace)]) - (send (new universe% [universe0 u] #,@args) last))]))])) + #`(let* ([esp (make-eventspace)] + [thd (eventspace-handler-thread esp)]) + (with-handlers ((exn:break? (lambda (x) (break-thread thd)))) + (parameterize ([current-eventspace esp]) + (send (new universe% [universe0 u] #,@args) last))))]))]))