Handle termination of rktwebview_prg through alive event mechanism.

This commit is contained in:
2026-04-11 16:51:02 +02:00
parent 7d2d3e0bd2
commit 40ad5a15a5

View File

@@ -569,6 +569,14 @@
)
|#
(define alive-error-event -94328)
(define (close-down-on-alive-error)
(rkt-webview-exit #f
"rktwebview_prg has stopped working, cannot continue"
) ; close without closing windows
)
(define (start-event-processing)
(thread (λ ()
(letrec
@@ -589,9 +597,12 @@
_string*/utf-8))
)
(rkt_webview_free_data rkt-evt)
(let ((cb (hash-ref evt-cb-hash wv #f)))
(unless (eq? cb #f)
(cb evt))))))
;(displayln (format "~a ~a" wv evt))
(if (= wv alive-error-event)
(close-down-on-alive-error)
(let ((cb (hash-ref evt-cb-hash wv #f)))
(unless (eq? cb #f)
(cb evt)))))))
(set! waiting (- waiting 1))
)
)
@@ -798,15 +809,25 @@
#f
#t)))
(define (rkt-webview-exit)
(let ((open-windows (hash->list rkt-wv-store)))
(for-each (λ (kv)
(let ((win (car kv))
(handle (cdr kv)))
(rkt-webview-close handle)))
open-windows))
(rkt_webview_cleanup)
(stop-event-processing)
(define (rkt-webview-exit . args)
(let ((cl-w (if (null? args) #f (car args)))
(msg (if (null? args) #f
(if (null? (cdr args))
#f
(cadr args))))
)
(when cl-w
(let ((open-windows (hash->list rkt-wv-store)))
(for-each (λ (kv)
(let ((win (car kv))
(handle (cdr kv)))
(rkt-webview-close handle)))
open-windows)))
(rkt_webview_cleanup)
(unless (eq? msg #f)
(error msg))
)
(stop-event-processing)
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;