initialization and cleanup

This commit is contained in:
2026-03-17 15:42:03 +01:00
parent 7c3b780ae9
commit c50267120a
9 changed files with 209 additions and 216 deletions

View File

@@ -11,6 +11,7 @@
json
racket/string
racket/path
"utils.rkt"
)
(provide rkt-wv
@@ -268,6 +269,10 @@
(define-rktwebview rkt_webview_init
(_fun -> _void))
;RKTWEBVIEW_QT_EXPORT void rkt_webview_cleanup();
(define-rktwebview rkt_webview_cleanup
(_fun -> _void))
;RKTWEBVIEW_QT_EXPORT rkt_wv_context_t rkt_webview_new_context(const char *boilerplate_js,
; const char *optional_server_cert_pem);
(define-rktwebview rkt_webview_new_context
@@ -392,20 +397,23 @@
;; Initialize and start library
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(define process-events #t)
(define process-events 'process)
(define (stop-event-processing)
(set! process-events #f))
(set! process-events 'stop)
(while (eq? process-events 'stop)
(sleep 0.001)))
(define (start-event-processing)
(thread (λ ()
(letrec ((f (λ ()
(rkt_webview_process_events 1)
(sleep 0.001)
(if process-events
(if (eq? process-events 'process)
(f)
(begin
(displayln "Stopping event processing")
(set! process-events 'stopped)
'done)))))
(f)))))
@@ -594,7 +602,9 @@
(handle (cdr kv)))
(rkt-webview-close handle)))
open-windows))
(stop-event-processing))
(stop-event-processing)
(rkt_webview_cleanup)
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Cleanup on exit