Bogdanp / racket-gui-easy

Declarative GUIs in Racket.
https://docs.racket-lang.org/gui-easy/index.html
134 stars 18 forks source link

popup-menu causing invalid memory reference errors #14

Closed benknoble closed 2 years ago

benknoble commented 2 years ago

Every variation on the following program I have tried has failed:

#lang racket
(require racket/gui/easy)
(define root (window (button "Pop" (thunk (render-popup-window root (popup-menu (menu-item "Click Me" (thunk (displayln "Hi")))))))))

A blur of "invalid memory reference" errors flies by, and not even C-\ can stop them (I have to kill the process). This was based partly on the popup in your video in #13.

Platform details:

Welcome to Racket v8.4 [cs].
OS: macOS Catalina 10.15.7 19H1824 x86_64 
Host: MacBookPro16,1 
Kernel: 19.6.0 
Uptime: 8 days, 4 hours, 21 mins 
Packages: 211 (brew) 
Shell: zsh 5.7.1 
Resolution: 1792x1120, 3008x1692 
DE: Aqua 
WM: Quartz Compositor 
WM Theme: Purple (Dark) 
Terminal: alacritty 
CPU: Intel i9-9880H (16) @ 2.30GHz 
GPU: Intel UHD Graphics 630, AMD Radeon Pro 5500M 
Memory: 10087MiB / 16384MiB 
Bogdanp commented 2 years ago

I'm unable to reproduce the issue, but your example is incomplete so I've had to change it a bit. This works for me:

#lang racket

(require racket/gui/easy)

(define root
  (render
   (window
    (button
     "Pop"
     (thunk
      (render-popup-menu
       root
       (popup-menu
        (menu-item "Click Me" (thunk (displayln "Hi"))))
       0 0))))))
benknoble commented 2 years ago

Oh, I missed the mouse-event parts. Still odd that I get the error, though. Adding those two arguments fixes it.

Could it be a bug with racket/gui that doesn't handle arity-errors correctly?

Bogdanp commented 2 years ago

Any arity errors should be (and seem to be) caught at the gui/easy level, so I'm not sure what exactly must've gone wrong. I've tried a couple things to get it to fail, like changing root to a different value, but everything I've tried just ends in a contract error, not a crash.