cs: fix glib logging callback

Commit 16ad9ed522 removed a `lock-object`, but that's only ok as long
as the callable is retained (which is better than using
`lock-object`).
This commit is contained in:
Matthew Flatt 2020-04-22 14:36:37 -06:00
parent e95c3e337d
commit 7c7d514f73

View File

@ -445,7 +445,9 @@
;; kind of a hack, it's much simpler to implement that here and
;; export the function pointer as a primitive.
(export glib-log-message)
(export glib-log-message
;; Make sure the callable is retained:
glib-log-message-callable)
(define G_LOG_LEVEL_ERROR 2)
(define G_LOG_LEVEL_CRITICAL 3)
@ -454,7 +456,7 @@
(define G_LOG_LEVEL_INFO 6)
(define G_LOG_LEVEL_DEBUG 7)
(define glib-log-message
(define-values (glib-log-message glib-log-message-callable)
(let ([glib-log-message
(lambda (domain glib-level message)
(let ([level (cond
@ -475,7 +477,9 @@
[else
(post-as-asynchronous-callback go)]))))])
(let ([callable (foreign-callable __collect_safe glib-log-message (string int string) void)])
(foreign-callable-entry-point callable))))
(values
(foreign-callable-entry-point callable)
callable))))
;; ----------------------------------------