[racket-dev] List-box% infinite loop (was: Bug report not confirmed)

From: Laurent (laurent.orseau at gmail.com)
Date: Sun Sep 15 10:58:56 EDT 2013

On Sun, Sep 15, 2013 at 4:34 PM, Robby Findler
<robby at eecs.northwestern.edu>wrote:

>
> What was the issue?
>

It was an infinite loop triggered by a particular callback in list-box%:

#lang racket/gui

(define my-frame (new frame% [label "my-frame"]
                      [min-width 200] [min-height 200]))

(define lb (new list-box%
                [parent my-frame]
                [label "values"]
                [choices '("a" "b")]
                [callback (λ(lb ev)
                            (displayln (send ev get-event-type))
                            (send lb clear)
                            (send lb set '("b"))
                            )]))

(send my-frame show #t)

Click on "b", this will trigger infinite events

It's actually the combination of the callback calling `clear' and `set'
that triggers this infinite loop.
The problem is easily solved by removing `(clear)', which is redundant with
`set' anyway (which I hadn't understood at first).

Laurent
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/dev/archive/attachments/20130915/d654d90b/attachment.html>

Posted on the dev mailing list.