Unfortunately, I'm not well versed in Racket's GUI library - I have done
a lot of GUI work in C and C++.
In the OS graphics [X, GDI, etc], the button and the icon are separate
objects: e.g., deleting the button will not also delete an icon attached
to it, so if the icon doesn't have its own handle, you'll lose it and
have a resource leak.
These things often are handled at higher level by the graphics libraries
- and Racket may do that [I don't know] - but my first thought would be
to name the icon separately, and then pass the name to the button
constructor. E.g.,
(define my-icon (close-icon))
(new button% (label my-icon "&Quit" 'left) ...)
I'm thinking that the button isn't functioning correctly because it
isn't being constructed improperly. Theoretically the reference to the
icon should be the same regardless, but a lot of the library is macro
code and who knows what it really expects. When in doubt I try to simplify.
YMMV,
George